0s autopkgtest [20:00:32]: starting date and time: 2025-05-03 20:00:32+0000 0s autopkgtest [20:00:32]: git checkout: 9986aa8c Merge branch 'skia/fix_network_interface' into 'ubuntu/production' 0s autopkgtest [20:00:32]: host juju-7f2275-prod-proposed-migration-environment-15; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.cs6p65e8/out --timeout-copy=6000 -a i386 --setup-commands /home/ubuntu/autopkgtest-cloud/worker-config-production/setup-canonical.sh --apt-pocket=proposed=src:pandas,src:python-zstandard,src:matplotlib --apt-upgrade pandas --timeout-short=300 --timeout-copy=20000 --timeout-test=20000 --timeout-build=20000 '--env=ADT_TEST_TRIGGERS=pandas/2.2.3+dfsg-9 python-zstandard/0.23.0-4 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-8.secgroup --name adt-questing-i386-pandas-20250503-200032-juju-7f2275-prod-proposed-migration-environment-15-826e4b4f-5ebf-4e69-9ba1-3b87528980b6 --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/ 56s autopkgtest [20:01:28]: testbed dpkg architecture: amd64 56s autopkgtest [20:01:28]: testbed apt version: 3.0.0 56s autopkgtest [20:01:28]: @@@@@@@@@@@@@@@@@@@@ test bed setup 57s autopkgtest [20:01:29]: testbed release detected to be: None 57s autopkgtest [20:01:29]: updating testbed package index (apt update) 58s Get:1 http://ftpmaster.internal/ubuntu questing-proposed InRelease [110 kB] 58s Hit:2 http://ftpmaster.internal/ubuntu questing InRelease 58s Hit:3 http://ftpmaster.internal/ubuntu questing-updates InRelease 58s Hit:4 http://ftpmaster.internal/ubuntu questing-security InRelease 58s Get:5 http://ftpmaster.internal/ubuntu questing-proposed/main Sources [149 kB] 58s Get:6 http://ftpmaster.internal/ubuntu questing-proposed/multiverse Sources [33.7 kB] 58s Get:7 http://ftpmaster.internal/ubuntu questing-proposed/universe Sources [1442 kB] 59s Get:8 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 Packages [203 kB] 59s Get:9 http://ftpmaster.internal/ubuntu questing-proposed/main i386 Packages [146 kB] 59s Get:10 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 Packages [1424 kB] 59s Get:11 http://ftpmaster.internal/ubuntu questing-proposed/universe i386 Packages [576 kB] 59s Get:12 http://ftpmaster.internal/ubuntu questing-proposed/multiverse i386 Packages [23.1 kB] 59s Get:13 http://ftpmaster.internal/ubuntu questing-proposed/multiverse amd64 Packages [48.6 kB] 59s Fetched 4155 kB in 1s (3499 kB/s) 60s Reading package lists... 61s autopkgtest [20:01:33]: upgrading testbed (apt dist-upgrade and autopurge) 61s Reading package lists... 61s Building dependency tree... 61s Reading state information... 62s Calculating upgrade...Starting pkgProblemResolver with broken count: 0 62s Starting 2 pkgProblemResolver with broken count: 0 62s Done 63s Entering ResolveByKeep 63s 63s Calculating upgrade... 63s The following packages will be upgraded: 63s cloud-init cloud-init-base debianutils libmbim-glib4 libmbim-proxy 63s libnftnl11 libqmi-glib5 libqmi-proxy libsepol2 python3-lazr.restfulclient 63s sos 63s 11 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 63s Need to get 2693 kB of archives. 63s After this operation, 104 kB disk space will be freed. 63s Get:1 http://ftpmaster.internal/ubuntu questing/main amd64 debianutils amd64 5.22 [93.0 kB] 64s Get:2 http://ftpmaster.internal/ubuntu questing/main amd64 libsepol2 amd64 3.8.1-1 [327 kB] 64s Get:3 http://ftpmaster.internal/ubuntu questing/main amd64 libnftnl11 amd64 1.2.9-1 [69.1 kB] 64s Get:4 http://ftpmaster.internal/ubuntu questing/main amd64 cloud-init-base all 25.2~1g7a0265d3-0ubuntu1 [619 kB] 64s Get:5 http://ftpmaster.internal/ubuntu questing/main amd64 libmbim-proxy amd64 1.32.0-1 [6276 B] 64s Get:6 http://ftpmaster.internal/ubuntu questing/main amd64 libmbim-glib4 amd64 1.32.0-1 [233 kB] 64s Get:7 http://ftpmaster.internal/ubuntu questing/main amd64 libqmi-proxy amd64 1.36.0-1 [6220 B] 64s Get:8 http://ftpmaster.internal/ubuntu questing/main amd64 libqmi-glib5 amd64 1.36.0-1 [920 kB] 64s Get:9 http://ftpmaster.internal/ubuntu questing/main amd64 python3-lazr.restfulclient all 0.14.6-3 [51.0 kB] 64s Get:10 http://ftpmaster.internal/ubuntu questing/main amd64 sos all 4.9.1-1 [367 kB] 64s Get:11 http://ftpmaster.internal/ubuntu questing/main amd64 cloud-init all 25.2~1g7a0265d3-0ubuntu1 [2106 B] 64s Preconfiguring packages ... 64s Fetched 2693 kB in 1s (3622 kB/s) 65s (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 ... 80514 files and directories currently installed.) 65s Preparing to unpack .../debianutils_5.22_amd64.deb ... 65s Unpacking debianutils (5.22) over (5.21) ... 65s Setting up debianutils (5.22) ... 65s (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 ... 80514 files and directories currently installed.) 65s Preparing to unpack .../libsepol2_3.8.1-1_amd64.deb ... 65s Unpacking libsepol2:amd64 (3.8.1-1) over (3.7-1) ... 65s Setting up libsepol2:amd64 (3.8.1-1) ... 65s (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 ... 80514 files and directories currently installed.) 65s Preparing to unpack .../0-libnftnl11_1.2.9-1_amd64.deb ... 65s Unpacking libnftnl11:amd64 (1.2.9-1) over (1.2.8-1) ... 65s Preparing to unpack .../1-cloud-init-base_25.2~1g7a0265d3-0ubuntu1_all.deb ... 65s Unpacking cloud-init-base (25.2~1g7a0265d3-0ubuntu1) over (25.1.1-0ubuntu2) ... 66s Preparing to unpack .../2-libmbim-proxy_1.32.0-1_amd64.deb ... 66s Unpacking libmbim-proxy (1.32.0-1) over (1.31.2-0ubuntu4) ... 66s Preparing to unpack .../3-libmbim-glib4_1.32.0-1_amd64.deb ... 66s Unpacking libmbim-glib4:amd64 (1.32.0-1) over (1.31.2-0ubuntu4) ... 66s Preparing to unpack .../4-libqmi-proxy_1.36.0-1_amd64.deb ... 66s Unpacking libqmi-proxy (1.36.0-1) over (1.35.6-1) ... 66s Preparing to unpack .../5-libqmi-glib5_1.36.0-1_amd64.deb ... 66s Unpacking libqmi-glib5:amd64 (1.36.0-1) over (1.35.6-1) ... 66s Preparing to unpack .../6-python3-lazr.restfulclient_0.14.6-3_all.deb ... 66s Unpacking python3-lazr.restfulclient (0.14.6-3) over (0.14.6-2) ... 66s Preparing to unpack .../7-sos_4.9.1-1_all.deb ... 66s Unpacking sos (4.9.1-1) over (4.9.0-6) ... 66s Preparing to unpack .../8-cloud-init_25.2~1g7a0265d3-0ubuntu1_all.deb ... 66s Unpacking cloud-init (25.2~1g7a0265d3-0ubuntu1) over (25.1.1-0ubuntu2) ... 66s Setting up sos (4.9.1-1) ... 67s Setting up libnftnl11:amd64 (1.2.9-1) ... 67s Setting up cloud-init-base (25.2~1g7a0265d3-0ubuntu1) ... 69s Setting up python3-lazr.restfulclient (0.14.6-3) ... 69s Setting up libmbim-glib4:amd64 (1.32.0-1) ... 69s Setting up cloud-init (25.2~1g7a0265d3-0ubuntu1) ... 69s Setting up libmbim-proxy (1.32.0-1) ... 69s Setting up libqmi-glib5:amd64 (1.36.0-1) ... 69s Setting up libqmi-proxy (1.36.0-1) ... 69s Processing triggers for libc-bin (2.41-6ubuntu1) ... 69s Processing triggers for rsyslog (8.2412.0-2ubuntu2) ... 69s Processing triggers for man-db (2.13.0-1) ... 71s Reading package lists... 72s Building dependency tree... 72s Reading state information... 72s Starting pkgProblemResolver with broken count: 0 72s Starting 2 pkgProblemResolver with broken count: 0 72s Done 73s Solving dependencies... 73s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 73s autopkgtest [20:01:45]: rebooting testbed after setup commands that affected boot 87s autopkgtest-virt-ssh: WARNING: ssh connection failed. Retrying in 3 seconds... 94s autopkgtest [20:02:06]: testbed running kernel: Linux 6.14.0-15-generic #15-Ubuntu SMP PREEMPT_DYNAMIC Sun Apr 6 15:05:05 UTC 2025 96s autopkgtest [20:02:08]: @@@@@@@@@@@@@@@@@@@@ apt-source pandas 100s Get:1 http://ftpmaster.internal/ubuntu questing-proposed/universe pandas 2.2.3+dfsg-9 (dsc) [5546 B] 100s Get:2 http://ftpmaster.internal/ubuntu questing-proposed/universe pandas 2.2.3+dfsg-9 (tar) [11.2 MB] 100s Get:3 http://ftpmaster.internal/ubuntu questing-proposed/universe pandas 2.2.3+dfsg-9 (diff) [112 kB] 100s gpgv: Signature made Sat Mar 29 14:46:18 2025 UTC 100s gpgv: using RSA key 67CB311005C4EDBE32175308DEE50D0D567EA266 100s gpgv: issuer "rebecca_palmer@zoho.com" 100s gpgv: Can't check signature: No public key 100s dpkg-source: warning: cannot verify inline signature for ./pandas_2.2.3+dfsg-9.dsc: no acceptable signature found 101s autopkgtest [20:02:13]: testing package pandas version 2.2.3+dfsg-9 102s autopkgtest [20:02:14]: build not needed 105s autopkgtest [20:02:17]: test command1: preparing testbed 106s Reading package lists... 106s Building dependency tree... 106s Reading state information... 106s Starting pkgProblemResolver with broken count: 0 106s Starting 2 pkgProblemResolver with broken count: 0 106s Done 107s The following NEW packages will be installed: 107s libblas3 libgfortran5 liblapack3 python3-numpy python3-numpy-dev 107s python3-pandas python3-pandas-lib python3-pytz 107s 0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded. 107s Need to get 18.5 MB of archives. 107s After this operation, 91.7 MB of additional disk space will be used. 107s Get:1 http://ftpmaster.internal/ubuntu questing/main amd64 python3-numpy-dev amd64 1:2.2.3+ds-5 [148 kB] 107s Get:2 http://ftpmaster.internal/ubuntu questing/main amd64 libblas3 amd64 3.12.1-2 [359 kB] 107s Get:3 http://ftpmaster.internal/ubuntu questing/main amd64 libgfortran5 amd64 15-20250404-0ubuntu1 [926 kB] 107s Get:4 http://ftpmaster.internal/ubuntu questing/main amd64 liblapack3 amd64 3.12.1-2 [3179 kB] 107s Get:5 http://ftpmaster.internal/ubuntu questing/main amd64 python3-numpy amd64 1:2.2.3+ds-5 [5702 kB] 108s Get:6 http://ftpmaster.internal/ubuntu questing/main amd64 python3-pytz all 2025.1-3 [162 kB] 108s Get:7 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-pandas-lib amd64 2.2.3+dfsg-9 [4949 kB] 108s Get:8 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-pandas all 2.2.3+dfsg-9 [3112 kB] 108s Fetched 18.5 MB in 1s (15.2 MB/s) 108s Selecting previously unselected package python3-numpy-dev:amd64. 109s (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 ... 80518 files and directories currently installed.) 109s Preparing to unpack .../0-python3-numpy-dev_1%3a2.2.3+ds-5_amd64.deb ... 109s Unpacking python3-numpy-dev:amd64 (1:2.2.3+ds-5) ... 109s Selecting previously unselected package libblas3:amd64. 109s Preparing to unpack .../1-libblas3_3.12.1-2_amd64.deb ... 109s Unpacking libblas3:amd64 (3.12.1-2) ... 109s Selecting previously unselected package libgfortran5:amd64. 109s Preparing to unpack .../2-libgfortran5_15-20250404-0ubuntu1_amd64.deb ... 109s Unpacking libgfortran5:amd64 (15-20250404-0ubuntu1) ... 109s Selecting previously unselected package liblapack3:amd64. 109s Preparing to unpack .../3-liblapack3_3.12.1-2_amd64.deb ... 109s Unpacking liblapack3:amd64 (3.12.1-2) ... 109s Selecting previously unselected package python3-numpy. 109s Preparing to unpack .../4-python3-numpy_1%3a2.2.3+ds-5_amd64.deb ... 109s Unpacking python3-numpy (1:2.2.3+ds-5) ... 109s Selecting previously unselected package python3-pytz. 109s Preparing to unpack .../5-python3-pytz_2025.1-3_all.deb ... 109s Unpacking python3-pytz (2025.1-3) ... 109s Selecting previously unselected package python3-pandas-lib:amd64. 109s Preparing to unpack .../6-python3-pandas-lib_2.2.3+dfsg-9_amd64.deb ... 109s Unpacking python3-pandas-lib:amd64 (2.2.3+dfsg-9) ... 109s Selecting previously unselected package python3-pandas. 109s Preparing to unpack .../7-python3-pandas_2.2.3+dfsg-9_all.deb ... 109s Unpacking python3-pandas (2.2.3+dfsg-9) ... 110s Setting up python3-pytz (2025.1-3) ... 110s Setting up libblas3:amd64 (3.12.1-2) ... 110s 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 110s Setting up python3-numpy-dev:amd64 (1:2.2.3+ds-5) ... 110s Setting up libgfortran5:amd64 (15-20250404-0ubuntu1) ... 110s Setting up liblapack3:amd64 (3.12.1-2) ... 110s 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 110s Setting up python3-numpy (1:2.2.3+ds-5) ... 112s Setting up python3-pandas-lib:amd64 (2.2.3+dfsg-9) ... 112s Setting up python3-pandas (2.2.3+dfsg-9) ... 117s Processing triggers for man-db (2.13.0-1) ... 118s Processing triggers for libc-bin (2.41-6ubuntu1) ... 119s autopkgtest [20:02:31]: testbed environment configured for cross-architecture building 119s autopkgtest [20:02:31]: test command1: cd "$AUTOPKGTEST_TMP" && python3 -c "import pandas;a=pandas.DataFrame([[1,2],[3,4]])" 119s autopkgtest [20:02:31]: test command1: [----------------------- 121s autopkgtest [20:02:33]: test command1: -----------------------] 121s autopkgtest [20:02:33]: test command1: - - - - - - - - - - results - - - - - - - - - - 121s command1 PASS 122s autopkgtest [20:02:34]: test unittests3: preparing testbed 122s Reading package lists... 122s Building dependency tree... 122s Reading state information... 123s Starting pkgProblemResolver with broken count: 1 123s Starting 2 pkgProblemResolver with broken count: 1 123s Investigating (0) python3-zstandard:amd64 < none -> 0.23.0-4 @un puN Ib > 123s Broken python3-zstandard:amd64 Depends on libzstd1:amd64 < 1.5.6+dfsg-2 @ii pK > (>= 1.5.7~) 123s Considering libzstd1:amd64 304 as a solution to python3-zstandard:amd64 4 123s Done 123s Some packages could not be installed. This may mean that you have 123s requested an impossible situation or if you are using the unstable 123s distribution that some required packages have not yet been created 123s or been moved out of Incoming. 123s The following information may help to resolve the situation: 123s 123s The following packages have unmet dependencies: 123s python3-zstandard : Depends: libzstd1 (>= 1.5.7~) but 1.5.6+dfsg-2 is to be installed 123s E: Unable to correct problems, you have held broken packages. 123s autopkgtest: WARNING: Test dependencies are unsatisfiable with using apt pinning. Retrying with using all packages from questing-proposed 123s Reading package lists... 123s Building dependency tree... 123s Reading state information... 124s Starting pkgProblemResolver with broken count: 0 124s Starting 2 pkgProblemResolver with broken count: 0 124s Done 124s The following NEW packages will be installed: 124s blt fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-mono 124s fonts-lyx libaec0 libavahi-client3 libavahi-common-data libavahi-common3 124s libblosc1 libblosc2-4 libcups2t64 libdeflate0 libdouble-conversion3 124s libdrm-intel1 libegl-mesa0 libegl1 libfontconfig1 libfontenc1 libgbm1 libgl1 124s libgl1-mesa-dri libglvnd0 libglx-mesa0 libglx0 libgomp1 libgraphite2-3 124s libharfbuzz0b libhdf5-310 libice6 libimagequant0 libinput-bin libinput10 124s libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs-jquery-ui liblbfgsb0 124s liblcms2-2 liblerc4 libmd4c0 libmtdev1t64 libopenjp2-7 libpciaccess0 124s libpcre2-16-0 libpixman-1-0 libqhull-r8.0 libqt5core5t64 libqt5dbus5t64 124s libqt5designer5 libqt5gui5t64 libqt5help5 libqt5network5t64 124s libqt5printsupport5t64 libqt5sql5t64 libqt5test5t64 libqt5widgets5t64 124s libqt5xml5t64 libraqm0 libsharpyuv0 libsm6 libsnappy1v5 libsz2 libtcl8.6 124s libtiff6 libtk8.6 libvulkan1 libwacom-common libwacom9 libwayland-client0 124s libwayland-server0 libwebp7 libwebpdemux2 libwebpmux3 libx11-xcb1 libxaw7 124s libxcb-dri3-0 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 124s libxcb-present0 libxcb-randr0 libxcb-render-util0 libxcb-render0 124s libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 124s libxcb-xinerama0 libxcb-xinput0 libxcb-xkb1 libxfont2 libxft2 124s libxkbcommon-x11-0 libxkbfile1 libxmu6 libxpm4 libxrandr2 libxrender1 124s libxshmfence1 libxslt1.1 libxss1 libxt6t64 libxxf86vm1 libzopfli1 124s locales-all mesa-libgallium python-matplotlib-data python-tables-data 124s python3-all python3-async-generator python3-bottleneck python3-brotli 124s python3-bs4 python3-click python3-cloudpickle python3-contourpy 124s python3-cpuinfo python3-cycler python3-dask python3-decorator 124s python3-defusedxml python3-et-xmlfile python3-execnet python3-fonttools 124s python3-fs python3-fsspec python3-greenlet python3-html5lib 124s python3-hypothesis python3-iniconfig python3-kiwisolver python3-locket 124s python3-lxml python3-lz4 python3-matplotlib python3-mpmath python3-numexpr 124s python3-odf python3-openpyxl python3-partd python3-pil python3-pil.imagetk 124s python3-platformdirs python3-pluggy python3-py python3-pyqt5 124s python3-pyqt5.sip python3-pyreadstat python3-pytest python3-pytest-asyncio 124s python3-pytest-forked python3-pytest-localserver python3-pytest-xdist 124s python3-pytestqt python3-scipy python3-sortedcontainers python3-soupsieve 124s python3-sqlalchemy python3-sympy python3-tables python3-tables-lib 124s python3-tabulate python3-tk python3-toolz python3-tz python3-ufolib2 124s python3-webencodings python3-werkzeug python3-xarray python3-xlrd 124s python3-xlsxwriter python3-zopfli python3-zstandard python3.13-tk 124s tk8.6-blt2.5 tzdata-legacy unicode-data x11-common x11-xkb-utils xsel 124s xserver-common xvfb 124s The following packages will be upgraded: 124s gcc-15-base libatomic1 libgcc-s1 libgfortran5 libpython3.13 124s libpython3.13-minimal libpython3.13-stdlib libstdc++6 libx11-6 libx11-data 124s libzstd1 python3-pytz python3.13 python3.13-gdbm python3.13-minimal tzdata 124s zstd 125s 17 upgraded, 187 newly installed, 0 to remove and 102 not upgraded. 125s Need to get 132 MB of archives. 125s After this operation, 675 MB of additional disk space will be used. 125s Get:1 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3.13 amd64 3.13.3-2 [739 kB] 125s Get:2 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libpython3.13 amd64 3.13.3-2 [2342 kB] 125s Get:3 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libpython3.13-stdlib amd64 3.13.3-2 [2071 kB] 125s Get:4 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3.13-minimal amd64 3.13.3-2 [2372 kB] 125s Get:5 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libpython3.13-minimal amd64 3.13.3-2 [884 kB] 125s Get:6 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 tzdata all 2025b-3ubuntu1 [198 kB] 125s Get:7 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libgfortran5 amd64 15.1.0-2ubuntu1 [924 kB] 125s Get:8 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 gcc-15-base amd64 15.1.0-2ubuntu1 [54.6 kB] 125s Get:9 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libgcc-s1 amd64 15.1.0-2ubuntu1 [78.1 kB] 125s Get:10 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libatomic1 amd64 15.1.0-2ubuntu1 [10.5 kB] 125s Get:11 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libstdc++6 amd64 15.1.0-2ubuntu1 [812 kB] 125s Get:12 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libzstd1 amd64 1.5.7+dfsg-1 [308 kB] 125s Get:13 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libx11-data all 2:1.8.12-1 [116 kB] 125s Get:14 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libx11-6 amd64 2:1.8.12-1 [656 kB] 125s Get:15 http://ftpmaster.internal/ubuntu questing/main amd64 libtcl8.6 amd64 8.6.16+dfsg-1 [1086 kB] 126s Get:16 http://ftpmaster.internal/ubuntu questing/main amd64 fonts-dejavu-mono all 2.37-8 [502 kB] 126s Get:17 http://ftpmaster.internal/ubuntu questing/main amd64 fonts-dejavu-core all 2.37-8 [835 kB] 126s Get:18 http://ftpmaster.internal/ubuntu questing/main amd64 fontconfig-config amd64 2.15.0-2.2ubuntu1 [37.8 kB] 126s Get:19 http://ftpmaster.internal/ubuntu questing/main amd64 libfontconfig1 amd64 2.15.0-2.2ubuntu1 [164 kB] 126s Get:20 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libxrender1 amd64 1:0.9.12-1 [19.8 kB] 126s Get:21 http://ftpmaster.internal/ubuntu questing/main amd64 libxft2 amd64 2.3.6-1build1 [45.3 kB] 126s Get:22 http://ftpmaster.internal/ubuntu questing/main amd64 x11-common all 1:7.7+23ubuntu4 [21.8 kB] 126s Get:23 http://ftpmaster.internal/ubuntu questing/main amd64 libxss1 amd64 1:1.2.3-1build3 [7204 B] 126s Get:24 http://ftpmaster.internal/ubuntu questing/main amd64 libtk8.6 amd64 8.6.16-1 [868 kB] 126s Get:25 http://ftpmaster.internal/ubuntu questing/main amd64 tk8.6-blt2.5 amd64 2.5.3+dfsg-8 [694 kB] 126s Get:26 http://ftpmaster.internal/ubuntu questing/main amd64 blt amd64 2.5.3+dfsg-8 [4824 B] 126s Get:27 http://ftpmaster.internal/ubuntu questing/main amd64 fontconfig amd64 2.15.0-2.2ubuntu1 [180 kB] 126s Get:28 http://ftpmaster.internal/ubuntu questing/universe amd64 fonts-lyx all 2.4.3-1 [171 kB] 126s Get:29 http://ftpmaster.internal/ubuntu questing/universe amd64 libaec0 amd64 1.1.3-1 [22.7 kB] 126s Get:30 http://ftpmaster.internal/ubuntu questing/main amd64 libavahi-common-data amd64 0.8-16ubuntu2 [31.0 kB] 126s Get:31 http://ftpmaster.internal/ubuntu questing/main amd64 libavahi-common3 amd64 0.8-16ubuntu2 [23.6 kB] 126s Get:32 http://ftpmaster.internal/ubuntu questing/main amd64 libavahi-client3 amd64 0.8-16ubuntu2 [27.5 kB] 126s Get:33 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libsnappy1v5 amd64 1.2.2-1 [30.9 kB] 126s Get:34 http://ftpmaster.internal/ubuntu questing/universe amd64 libblosc1 amd64 1.21.5+ds-1build1 [36.2 kB] 126s Get:35 http://ftpmaster.internal/ubuntu questing/universe amd64 libblosc2-4 amd64 2.17.1+ds-1 [171 kB] 126s Get:36 http://ftpmaster.internal/ubuntu questing/main amd64 libcups2t64 amd64 2.4.12-0ubuntu1 [292 kB] 126s Get:37 http://ftpmaster.internal/ubuntu questing/main amd64 libdeflate0 amd64 1.23-2 [49.9 kB] 126s Get:38 http://ftpmaster.internal/ubuntu questing/universe amd64 libdouble-conversion3 amd64 3.3.1-1 [41.7 kB] 126s Get:39 http://ftpmaster.internal/ubuntu questing/main amd64 libpciaccess0 amd64 0.17-3build1 [18.6 kB] 126s Get:40 http://ftpmaster.internal/ubuntu questing/main amd64 libdrm-intel1 amd64 2.4.124-2 [68.9 kB] 126s Get:41 http://ftpmaster.internal/ubuntu questing/main amd64 libwayland-server0 amd64 1.23.1-3 [37.2 kB] 126s Get:42 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libx11-xcb1 amd64 2:1.8.12-1 [7968 B] 126s Get:43 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-dri3-0 amd64 1.17.0-2 [7508 B] 126s Get:44 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-present0 amd64 1.17.0-2 [6064 B] 126s Get:45 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-randr0 amd64 1.17.0-2 [17.9 kB] 126s Get:46 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-sync1 amd64 1.17.0-2 [9312 B] 126s Get:47 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-xfixes0 amd64 1.17.0-2 [10.2 kB] 126s Get:48 http://ftpmaster.internal/ubuntu questing/main amd64 libxshmfence1 amd64 1.3.3-1 [5262 B] 126s Get:49 http://ftpmaster.internal/ubuntu questing/main amd64 mesa-libgallium amd64 25.0.3-1ubuntu2 [12.1 MB] 126s Get:50 http://ftpmaster.internal/ubuntu questing/main amd64 libgbm1 amd64 25.0.3-1ubuntu2 [33.4 kB] 126s Get:51 http://ftpmaster.internal/ubuntu questing/main amd64 libwayland-client0 amd64 1.23.1-3 [29.7 kB] 126s Get:52 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-shm0 amd64 1.17.0-2 [5758 B] 126s Get:53 http://ftpmaster.internal/ubuntu questing/main amd64 libegl-mesa0 amd64 25.0.3-1ubuntu2 [136 kB] 126s Get:54 http://ftpmaster.internal/ubuntu questing/main amd64 libfontenc1 amd64 1:1.1.8-1build1 [14.0 kB] 126s Get:55 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libvulkan1 amd64 1.4.309.0-1 [145 kB] 126s Get:56 http://ftpmaster.internal/ubuntu questing/main amd64 libgl1-mesa-dri amd64 25.0.3-1ubuntu2 [35.7 kB] 126s Get:57 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-glx0 amd64 1.17.0-2 [24.8 kB] 126s Get:58 http://ftpmaster.internal/ubuntu questing/main amd64 libxxf86vm1 amd64 1:1.1.4-1build4 [9282 B] 126s Get:59 http://ftpmaster.internal/ubuntu questing/main amd64 libglx-mesa0 amd64 25.0.3-1ubuntu2 [146 kB] 126s Get:60 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libgomp1 amd64 15.1.0-2ubuntu1 [151 kB] 126s Get:61 http://ftpmaster.internal/ubuntu questing/main amd64 libgraphite2-3 amd64 1.3.14-2ubuntu1 [73.1 kB] 126s Get:62 http://ftpmaster.internal/ubuntu questing/main amd64 libharfbuzz0b amd64 10.2.0-1 [543 kB] 126s Get:63 http://ftpmaster.internal/ubuntu questing/universe amd64 libsz2 amd64 1.1.3-1 [5456 B] 126s Get:64 http://ftpmaster.internal/ubuntu questing/universe amd64 libhdf5-310 amd64 1.14.5+repack-3 [1519 kB] 126s Get:65 http://ftpmaster.internal/ubuntu questing/main amd64 libice6 amd64 2:1.1.1-1 [44.1 kB] 126s Get:66 http://ftpmaster.internal/ubuntu questing/main amd64 libimagequant0 amd64 2.18.0-1build1 [36.3 kB] 126s Get:67 http://ftpmaster.internal/ubuntu questing/main amd64 libwacom-common all 2.14.0-1 [103 kB] 126s Get:68 http://ftpmaster.internal/ubuntu questing/main amd64 libwacom9 amd64 2.14.0-1 [27.3 kB] 126s Get:69 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libinput-bin amd64 1.28.1-1 [23.6 kB] 126s Get:70 http://ftpmaster.internal/ubuntu questing/main amd64 libmtdev1t64 amd64 1.1.7-1 [16.3 kB] 126s Get:71 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libinput10 amd64 1.28.1-1 [144 kB] 126s Get:72 http://ftpmaster.internal/ubuntu questing/main amd64 libjpeg-turbo8 amd64 2.1.5-3ubuntu2 [179 kB] 126s Get:73 http://ftpmaster.internal/ubuntu questing/main amd64 libjpeg8 amd64 8c-2ubuntu11 [2148 B] 126s Get:74 http://ftpmaster.internal/ubuntu questing/main amd64 libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 126s Get:75 http://ftpmaster.internal/ubuntu questing/universe amd64 libjs-jquery-ui all 1.13.2+dfsg-1 [252 kB] 126s Get:76 http://ftpmaster.internal/ubuntu questing/universe amd64 liblbfgsb0 amd64 3.0+dfsg.4-1build1 [29.9 kB] 126s Get:77 http://ftpmaster.internal/ubuntu questing/main amd64 liblcms2-2 amd64 2.16-2 [212 kB] 127s Get:78 http://ftpmaster.internal/ubuntu questing/main amd64 liblerc4 amd64 4.0.0+ds-5ubuntu1 [271 kB] 127s Get:79 http://ftpmaster.internal/ubuntu questing/universe amd64 libmd4c0 amd64 0.5.2-2 [50.1 kB] 127s Get:80 http://ftpmaster.internal/ubuntu questing/main amd64 libpcre2-16-0 amd64 10.45-1 [268 kB] 127s Get:81 http://ftpmaster.internal/ubuntu questing/main amd64 libpixman-1-0 amd64 0.44.0-3 [427 kB] 127s Get:82 http://ftpmaster.internal/ubuntu questing/universe amd64 libqhull-r8.0 amd64 2020.2-6build1 [193 kB] 127s Get:83 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5core5t64 amd64 5.15.15+dfsg-4ubuntu1 [2038 kB] 127s Get:84 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5dbus5t64 amd64 5.15.15+dfsg-4ubuntu1 [221 kB] 127s Get:85 http://ftpmaster.internal/ubuntu questing/main amd64 libglvnd0 amd64 1.7.0-1build1 [69.6 kB] 127s Get:86 http://ftpmaster.internal/ubuntu questing/main amd64 libegl1 amd64 1.7.0-1build1 [28.7 kB] 127s Get:87 http://ftpmaster.internal/ubuntu questing/main amd64 libglx0 amd64 1.7.0-1build1 [38.6 kB] 127s Get:88 http://ftpmaster.internal/ubuntu questing/main amd64 libgl1 amd64 1.7.0-1build1 [102 kB] 127s Get:89 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5network5t64 amd64 5.15.15+dfsg-4ubuntu1 [725 kB] 127s Get:90 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libsm6 amd64 2:1.2.6-1 [16.4 kB] 127s Get:91 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-icccm4 amd64 0.4.2-1 [11.1 kB] 127s Get:92 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-util1 amd64 0.4.1-1 [11.2 kB] 127s Get:93 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-image0 amd64 0.4.0-2build1 [10.8 kB] 127s Get:94 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-keysyms1 amd64 0.4.1-1 [8738 B] 127s Get:95 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-render0 amd64 1.17.0-2 [16.2 kB] 127s Get:96 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-render-util0 amd64 0.3.10-1 [10.8 kB] 127s Get:97 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-shape0 amd64 1.17.0-2 [6092 B] 127s Get:98 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-xinerama0 amd64 1.17.0-2 [5412 B] 127s Get:99 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-xinput0 amd64 1.17.0-2 [33.2 kB] 127s Get:100 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-xkb1 amd64 1.17.0-2 [32.3 kB] 127s Get:101 http://ftpmaster.internal/ubuntu questing/main amd64 libxkbcommon-x11-0 amd64 1.7.0-2 [15.2 kB] 127s Get:102 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5gui5t64 amd64 5.15.15+dfsg-4ubuntu1 [3791 kB] 127s Get:103 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5widgets5t64 amd64 5.15.15+dfsg-4ubuntu1 [2560 kB] 127s Get:104 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5xml5t64 amd64 5.15.15+dfsg-4ubuntu1 [124 kB] 127s Get:105 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5designer5 amd64 5.15.15-6build1 [2827 kB] 128s Get:106 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5sql5t64 amd64 5.15.15+dfsg-4ubuntu1 [122 kB] 128s Get:107 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5help5 amd64 5.15.15-6build1 [162 kB] 128s Get:108 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5printsupport5t64 amd64 5.15.15+dfsg-4ubuntu1 [208 kB] 128s Get:109 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5test5t64 amd64 5.15.15+dfsg-4ubuntu1 [149 kB] 128s Get:110 http://ftpmaster.internal/ubuntu questing/main amd64 libraqm0 amd64 0.10.2-1 [17.2 kB] 128s Get:111 http://ftpmaster.internal/ubuntu questing/main amd64 libsharpyuv0 amd64 1.5.0-0.1 [25.9 kB] 128s Get:112 http://ftpmaster.internal/ubuntu questing/main amd64 libjbig0 amd64 2.1-6.1ubuntu2 [29.7 kB] 128s Get:113 http://ftpmaster.internal/ubuntu questing/main amd64 libwebp7 amd64 1.5.0-0.1 [378 kB] 128s Get:114 http://ftpmaster.internal/ubuntu questing/main amd64 libtiff6 amd64 4.7.0-3ubuntu1 [204 kB] 128s Get:115 http://ftpmaster.internal/ubuntu questing/main amd64 libwebpdemux2 amd64 1.5.0-0.1 [13.0 kB] 128s Get:116 http://ftpmaster.internal/ubuntu questing/main amd64 libwebpmux3 amd64 1.5.0-0.1 [27.6 kB] 128s Get:117 http://ftpmaster.internal/ubuntu questing/main amd64 libxt6t64 amd64 1:1.2.1-1.2build1 [171 kB] 128s Get:118 http://ftpmaster.internal/ubuntu questing/main amd64 libxmu6 amd64 2:1.1.3-3build2 [47.6 kB] 128s Get:119 http://ftpmaster.internal/ubuntu questing/main amd64 libxpm4 amd64 1:3.5.17-1build2 [36.5 kB] 128s Get:120 http://ftpmaster.internal/ubuntu questing/main amd64 libxaw7 amd64 2:1.0.16-1 [207 kB] 128s Get:121 http://ftpmaster.internal/ubuntu questing/main amd64 libxfont2 amd64 1:2.0.6-1build1 [93.0 kB] 128s Get:122 http://ftpmaster.internal/ubuntu questing/main amd64 libxkbfile1 amd64 1:1.1.0-1build4 [70.0 kB] 128s Get:123 http://ftpmaster.internal/ubuntu questing/main amd64 libxrandr2 amd64 2:1.5.4-1 [19.6 kB] 128s Get:124 http://ftpmaster.internal/ubuntu questing/main amd64 libxslt1.1 amd64 1.1.39-0exp1ubuntu4 [176 kB] 128s Get:125 http://ftpmaster.internal/ubuntu questing/universe amd64 libzopfli1 amd64 1.0.3-3 [141 kB] 128s Get:126 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python-matplotlib-data all 3.10.1+dfsg1-3 [2936 kB] 128s Get:127 http://ftpmaster.internal/ubuntu questing/universe amd64 python-tables-data all 3.10.2-2build1 [49.7 kB] 128s Get:128 http://ftpmaster.internal/ubuntu questing/main amd64 python3-all amd64 3.13.3-1 [882 B] 128s Get:129 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-async-generator all 1.10-4 [17.5 kB] 128s Get:130 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-bottleneck amd64 1.4.2+ds1-2build1 [91.2 kB] 128s Get:131 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-brotli amd64 1.1.0-2build4 [367 kB] 128s Get:132 http://ftpmaster.internal/ubuntu questing/main amd64 python3-soupsieve all 2.7-1 [33.5 kB] 128s Get:133 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3-bs4 all 4.13.4-1 [137 kB] 128s Get:134 http://ftpmaster.internal/ubuntu questing/main amd64 python3-click all 8.2.0+0.really.8.1.8-1 [80.0 kB] 128s Get:135 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-cloudpickle all 3.1.1-1 [22.4 kB] 128s Get:136 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-contourpy amd64 1.3.1-1build1 [218 kB] 128s Get:137 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-cpuinfo all 9.0.0+git20221119-3 [21.7 kB] 128s Get:138 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-cycler all 0.12.1-1 [9716 B] 128s Get:139 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-fsspec all 2025.3.2-1 [217 kB] 128s Get:140 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-toolz all 1.0.0-2 [45.0 kB] 128s Get:141 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-locket all 1.0.0-2 [5872 B] 128s Get:142 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-partd all 1.4.2-1 [15.7 kB] 128s Get:143 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-dask all 2024.12.1+dfsg-2 [875 kB] 128s Get:144 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3-decorator all 5.2.1-2 [28.1 kB] 128s Get:145 http://ftpmaster.internal/ubuntu questing/main amd64 python3-defusedxml all 0.7.1-3 [42.2 kB] 128s Get:146 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-et-xmlfile all 2.0.0-1 [79.4 kB] 128s Get:147 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-execnet all 2.1.1-1 [33.4 kB] 128s Get:148 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3-platformdirs all 4.3.7-1 [16.9 kB] 128s Get:149 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-fs all 2.4.16-7 [90.8 kB] 128s Get:150 http://ftpmaster.internal/ubuntu questing/main amd64 python3-lxml amd64 5.3.2-1 [1407 kB] 128s Get:151 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-lz4 amd64 4.4.0+dfsg-2 [26.6 kB] 128s Get:152 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-scipy amd64 1.14.1-4ubuntu2 [18.7 MB] 129s Get:153 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-mpmath all 1.3.0-1 [425 kB] 129s Get:154 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-sympy all 1.13.3-5 [4229 kB] 129s Get:155 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-ufolib2 all 0.17.1+dfsg1-1 [33.5 kB] 129s Get:156 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-zopfli amd64 0.2.3.post1-1 [10.8 kB] 129s Get:157 http://ftpmaster.internal/ubuntu questing/universe amd64 unicode-data all 15.1.0-1 [8878 kB] 129s Get:158 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-fonttools amd64 4.57.0-1 [1497 kB] 129s Get:159 http://ftpmaster.internal/ubuntu questing/main amd64 python3-webencodings all 0.5.1-5 [11.5 kB] 129s Get:160 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3-html5lib all 1.2-2 [90.6 kB] 129s Get:161 http://ftpmaster.internal/ubuntu questing/main amd64 python3-sortedcontainers all 2.4.0-2 [27.6 kB] 129s Get:162 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-hypothesis all 6.130.5-1 [341 kB] 129s Get:163 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-iniconfig all 1.1.1-2 [6024 B] 129s Get:164 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-kiwisolver amd64 1.4.7-3build1 [55.6 kB] 129s Get:165 http://ftpmaster.internal/ubuntu questing/main amd64 libopenjp2-7 amd64 2.5.3-2 [218 kB] 129s Get:166 http://ftpmaster.internal/ubuntu questing/main amd64 python3-pil amd64 11.1.0-5build1 [583 kB] 129s Get:167 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3.13-tk amd64 3.13.3-2 [107 kB] 129s Get:168 http://ftpmaster.internal/ubuntu questing/main amd64 python3-tk amd64 3.13.3-1 [9856 B] 129s Get:169 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pil.imagetk amd64 11.1.0-5build1 [9828 B] 129s Get:170 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-matplotlib amd64 3.10.1+dfsg1-3 [18.1 MB] 130s Get:171 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-numexpr amd64 2.10.2-1build2 [131 kB] 130s Get:172 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-odf all 1.4.2-4 [79.0 kB] 130s Get:173 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-openpyxl all 3.1.5+dfsg-2 [152 kB] 130s Get:174 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pluggy all 1.5.0-1 [21.0 kB] 130s Get:175 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-py all 1.11.0-4 [72.7 kB] 130s Get:176 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pyqt5.sip amd64 12.17.0-1build1 [76.5 kB] 130s Get:177 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pyqt5 amd64 5.15.11+dfsg-2 [2725 kB] 130s Get:178 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pyreadstat amd64 1.2.8-1build1 [438 kB] 130s Get:179 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-pytest all 8.3.5-2 [252 kB] 130s Get:180 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest-asyncio all 0.25.1-1 [17.0 kB] 130s Get:181 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest-forked all 1.6.0-3 [7470 B] 130s Get:182 http://ftpmaster.internal/ubuntu questing/main amd64 python3-werkzeug all 3.1.3-2 [169 kB] 130s Get:183 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest-localserver all 0.9.0.post0-1 [21.9 kB] 130s Get:184 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest-xdist all 3.6.1-1 [33.8 kB] 130s Get:185 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytestqt all 4.4.0-1 [32.4 kB] 130s Get:186 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3-pytz all 2025.2-2 [163 kB] 130s Get:187 http://ftpmaster.internal/ubuntu questing/main amd64 python3-greenlet amd64 3.1.0-1build1 [166 kB] 130s Get:188 http://ftpmaster.internal/ubuntu questing/main amd64 python3-sqlalchemy all 2.0.38+ds1-0ubuntu2 [1215 kB] 130s Get:189 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-tables-lib amd64 3.10.2-2build1 [588 kB] 130s Get:190 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-tables all 3.10.2-2build1 [354 kB] 130s Get:191 http://ftpmaster.internal/ubuntu questing/main amd64 python3-tabulate all 0.9.0-1 [45.3 kB] 130s Get:192 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3-tz all 2025.2-2 [1860 B] 130s Get:193 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-xarray all 2025.03.1-4 [831 kB] 131s Get:194 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-xlrd all 2.0.1-2 [83.1 kB] 131s Get:195 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-xlsxwriter all 3.1.9-2 [462 kB] 131s Get:196 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-zstandard amd64 0.23.0-4 [383 kB] 131s Get:197 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3.13-gdbm amd64 3.13.3-2 [32.1 kB] 131s Get:198 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 tzdata-legacy all 2025b-3ubuntu1 [99.3 kB] 131s Get:199 http://ftpmaster.internal/ubuntu questing/main amd64 x11-xkb-utils amd64 7.7+9 [169 kB] 131s Get:200 http://ftpmaster.internal/ubuntu questing/universe amd64 xsel amd64 1.2.1-1 [20.5 kB] 131s Get:201 http://ftpmaster.internal/ubuntu questing/main amd64 xserver-common all 2:21.1.16-1ubuntu1 [34.4 kB] 131s Get:202 http://ftpmaster.internal/ubuntu questing/universe amd64 xvfb amd64 2:21.1.16-1ubuntu1 [975 kB] 131s Get:203 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 zstd amd64 1.5.7+dfsg-1 [672 kB] 131s Get:204 http://ftpmaster.internal/ubuntu questing/universe amd64 locales-all amd64 2.41-6ubuntu1 [11.2 MB] 133s Preconfiguring packages ... 133s Fetched 132 MB in 8s (17.4 MB/s) 133s (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 ... 83768 files and directories currently installed.) 133s Preparing to unpack .../0-python3.13_3.13.3-2_amd64.deb ... 133s Unpacking python3.13 (3.13.3-2) over (3.13.3-1) ... 133s Preparing to unpack .../1-libpython3.13_3.13.3-2_amd64.deb ... 133s Unpacking libpython3.13:amd64 (3.13.3-2) over (3.13.3-1) ... 133s Preparing to unpack .../2-libpython3.13-stdlib_3.13.3-2_amd64.deb ... 133s Unpacking libpython3.13-stdlib:amd64 (3.13.3-2) over (3.13.3-1) ... 133s Preparing to unpack .../3-python3.13-minimal_3.13.3-2_amd64.deb ... 133s Unpacking python3.13-minimal (3.13.3-2) over (3.13.3-1) ... 133s Preparing to unpack .../4-libpython3.13-minimal_3.13.3-2_amd64.deb ... 133s Unpacking libpython3.13-minimal:amd64 (3.13.3-2) over (3.13.3-1) ... 134s Preparing to unpack .../5-tzdata_2025b-3ubuntu1_all.deb ... 134s Unpacking tzdata (2025b-3ubuntu1) over (2025b-1ubuntu1) ... 134s Preparing to unpack .../6-libgfortran5_15.1.0-2ubuntu1_amd64.deb ... 134s Unpacking libgfortran5:amd64 (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 134s Preparing to unpack .../7-gcc-15-base_15.1.0-2ubuntu1_amd64.deb ... 134s Unpacking gcc-15-base:amd64 (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 134s Setting up gcc-15-base:amd64 (15.1.0-2ubuntu1) ... 134s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 83768 files and directories currently installed.) 134s Preparing to unpack .../libgcc-s1_15.1.0-2ubuntu1_amd64.deb ... 134s Unpacking libgcc-s1:amd64 (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 134s Setting up libgcc-s1:amd64 (15.1.0-2ubuntu1) ... 134s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 83768 files and directories currently installed.) 134s Preparing to unpack .../libatomic1_15.1.0-2ubuntu1_amd64.deb ... 134s Unpacking libatomic1:amd64 (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 134s Preparing to unpack .../libstdc++6_15.1.0-2ubuntu1_amd64.deb ... 134s Unpacking libstdc++6:amd64 (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 134s Setting up libstdc++6:amd64 (15.1.0-2ubuntu1) ... 134s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 83768 files and directories currently installed.) 134s Preparing to unpack .../libzstd1_1.5.7+dfsg-1_amd64.deb ... 134s Unpacking libzstd1:amd64 (1.5.7+dfsg-1) over (1.5.6+dfsg-2) ... 134s Setting up libzstd1:amd64 (1.5.7+dfsg-1) ... 134s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 83768 files and directories currently installed.) 134s Preparing to unpack .../000-libx11-data_2%3a1.8.12-1_all.deb ... 134s Unpacking libx11-data (2:1.8.12-1) over (2:1.8.10-2) ... 134s Preparing to unpack .../001-libx11-6_2%3a1.8.12-1_amd64.deb ... 134s Unpacking libx11-6:amd64 (2:1.8.12-1) over (2:1.8.10-2) ... 134s Selecting previously unselected package libtcl8.6:amd64. 134s Preparing to unpack .../002-libtcl8.6_8.6.16+dfsg-1_amd64.deb ... 134s Unpacking libtcl8.6:amd64 (8.6.16+dfsg-1) ... 135s Selecting previously unselected package fonts-dejavu-mono. 135s Preparing to unpack .../003-fonts-dejavu-mono_2.37-8_all.deb ... 135s Unpacking fonts-dejavu-mono (2.37-8) ... 135s Selecting previously unselected package fonts-dejavu-core. 135s Preparing to unpack .../004-fonts-dejavu-core_2.37-8_all.deb ... 135s Unpacking fonts-dejavu-core (2.37-8) ... 135s Selecting previously unselected package fontconfig-config. 135s Preparing to unpack .../005-fontconfig-config_2.15.0-2.2ubuntu1_amd64.deb ... 135s Unpacking fontconfig-config (2.15.0-2.2ubuntu1) ... 135s Selecting previously unselected package libfontconfig1:amd64. 135s Preparing to unpack .../006-libfontconfig1_2.15.0-2.2ubuntu1_amd64.deb ... 135s Unpacking libfontconfig1:amd64 (2.15.0-2.2ubuntu1) ... 135s Selecting previously unselected package libxrender1:amd64. 135s Preparing to unpack .../007-libxrender1_1%3a0.9.12-1_amd64.deb ... 135s Unpacking libxrender1:amd64 (1:0.9.12-1) ... 135s Selecting previously unselected package libxft2:amd64. 135s Preparing to unpack .../008-libxft2_2.3.6-1build1_amd64.deb ... 135s Unpacking libxft2:amd64 (2.3.6-1build1) ... 135s Selecting previously unselected package x11-common. 135s Preparing to unpack .../009-x11-common_1%3a7.7+23ubuntu4_all.deb ... 135s Unpacking x11-common (1:7.7+23ubuntu4) ... 135s Selecting previously unselected package libxss1:amd64. 135s Preparing to unpack .../010-libxss1_1%3a1.2.3-1build3_amd64.deb ... 135s Unpacking libxss1:amd64 (1:1.2.3-1build3) ... 135s Selecting previously unselected package libtk8.6:amd64. 135s Preparing to unpack .../011-libtk8.6_8.6.16-1_amd64.deb ... 135s Unpacking libtk8.6:amd64 (8.6.16-1) ... 135s Selecting previously unselected package tk8.6-blt2.5. 135s Preparing to unpack .../012-tk8.6-blt2.5_2.5.3+dfsg-8_amd64.deb ... 135s Unpacking tk8.6-blt2.5 (2.5.3+dfsg-8) ... 135s Selecting previously unselected package blt. 135s Preparing to unpack .../013-blt_2.5.3+dfsg-8_amd64.deb ... 135s Unpacking blt (2.5.3+dfsg-8) ... 135s Selecting previously unselected package fontconfig. 135s Preparing to unpack .../014-fontconfig_2.15.0-2.2ubuntu1_amd64.deb ... 135s Unpacking fontconfig (2.15.0-2.2ubuntu1) ... 135s Selecting previously unselected package fonts-lyx. 135s Preparing to unpack .../015-fonts-lyx_2.4.3-1_all.deb ... 135s Unpacking fonts-lyx (2.4.3-1) ... 135s Selecting previously unselected package libaec0:amd64. 135s Preparing to unpack .../016-libaec0_1.1.3-1_amd64.deb ... 135s Unpacking libaec0:amd64 (1.1.3-1) ... 135s Selecting previously unselected package libavahi-common-data:amd64. 135s Preparing to unpack .../017-libavahi-common-data_0.8-16ubuntu2_amd64.deb ... 135s Unpacking libavahi-common-data:amd64 (0.8-16ubuntu2) ... 135s Selecting previously unselected package libavahi-common3:amd64. 135s Preparing to unpack .../018-libavahi-common3_0.8-16ubuntu2_amd64.deb ... 135s Unpacking libavahi-common3:amd64 (0.8-16ubuntu2) ... 136s Selecting previously unselected package libavahi-client3:amd64. 136s Preparing to unpack .../019-libavahi-client3_0.8-16ubuntu2_amd64.deb ... 136s Unpacking libavahi-client3:amd64 (0.8-16ubuntu2) ... 136s Selecting previously unselected package libsnappy1v5:amd64. 136s Preparing to unpack .../020-libsnappy1v5_1.2.2-1_amd64.deb ... 136s Unpacking libsnappy1v5:amd64 (1.2.2-1) ... 136s Selecting previously unselected package libblosc1:amd64. 136s Preparing to unpack .../021-libblosc1_1.21.5+ds-1build1_amd64.deb ... 136s Unpacking libblosc1:amd64 (1.21.5+ds-1build1) ... 136s Selecting previously unselected package libblosc2-4:amd64. 136s Preparing to unpack .../022-libblosc2-4_2.17.1+ds-1_amd64.deb ... 136s Unpacking libblosc2-4:amd64 (2.17.1+ds-1) ... 136s Selecting previously unselected package libcups2t64:amd64. 136s Preparing to unpack .../023-libcups2t64_2.4.12-0ubuntu1_amd64.deb ... 136s Unpacking libcups2t64:amd64 (2.4.12-0ubuntu1) ... 136s Selecting previously unselected package libdeflate0:amd64. 136s Preparing to unpack .../024-libdeflate0_1.23-2_amd64.deb ... 136s Unpacking libdeflate0:amd64 (1.23-2) ... 136s Selecting previously unselected package libdouble-conversion3:amd64. 136s Preparing to unpack .../025-libdouble-conversion3_3.3.1-1_amd64.deb ... 136s Unpacking libdouble-conversion3:amd64 (3.3.1-1) ... 136s Selecting previously unselected package libpciaccess0:amd64. 136s Preparing to unpack .../026-libpciaccess0_0.17-3build1_amd64.deb ... 136s Unpacking libpciaccess0:amd64 (0.17-3build1) ... 136s Selecting previously unselected package libdrm-intel1:amd64. 136s Preparing to unpack .../027-libdrm-intel1_2.4.124-2_amd64.deb ... 136s Unpacking libdrm-intel1:amd64 (2.4.124-2) ... 136s Selecting previously unselected package libwayland-server0:amd64. 136s Preparing to unpack .../028-libwayland-server0_1.23.1-3_amd64.deb ... 136s Unpacking libwayland-server0:amd64 (1.23.1-3) ... 136s Selecting previously unselected package libx11-xcb1:amd64. 136s Preparing to unpack .../029-libx11-xcb1_2%3a1.8.12-1_amd64.deb ... 136s Unpacking libx11-xcb1:amd64 (2:1.8.12-1) ... 136s Selecting previously unselected package libxcb-dri3-0:amd64. 136s Preparing to unpack .../030-libxcb-dri3-0_1.17.0-2_amd64.deb ... 136s Unpacking libxcb-dri3-0:amd64 (1.17.0-2) ... 136s Selecting previously unselected package libxcb-present0:amd64. 136s Preparing to unpack .../031-libxcb-present0_1.17.0-2_amd64.deb ... 136s Unpacking libxcb-present0:amd64 (1.17.0-2) ... 136s Selecting previously unselected package libxcb-randr0:amd64. 136s Preparing to unpack .../032-libxcb-randr0_1.17.0-2_amd64.deb ... 136s Unpacking libxcb-randr0:amd64 (1.17.0-2) ... 136s Selecting previously unselected package libxcb-sync1:amd64. 136s Preparing to unpack .../033-libxcb-sync1_1.17.0-2_amd64.deb ... 136s Unpacking libxcb-sync1:amd64 (1.17.0-2) ... 136s Selecting previously unselected package libxcb-xfixes0:amd64. 136s Preparing to unpack .../034-libxcb-xfixes0_1.17.0-2_amd64.deb ... 136s Unpacking libxcb-xfixes0:amd64 (1.17.0-2) ... 136s Selecting previously unselected package libxshmfence1:amd64. 136s Preparing to unpack .../035-libxshmfence1_1.3.3-1_amd64.deb ... 136s Unpacking libxshmfence1:amd64 (1.3.3-1) ... 136s Selecting previously unselected package mesa-libgallium:amd64. 136s Preparing to unpack .../036-mesa-libgallium_25.0.3-1ubuntu2_amd64.deb ... 136s Unpacking mesa-libgallium:amd64 (25.0.3-1ubuntu2) ... 136s Selecting previously unselected package libgbm1:amd64. 136s Preparing to unpack .../037-libgbm1_25.0.3-1ubuntu2_amd64.deb ... 136s Unpacking libgbm1:amd64 (25.0.3-1ubuntu2) ... 136s Selecting previously unselected package libwayland-client0:amd64. 136s Preparing to unpack .../038-libwayland-client0_1.23.1-3_amd64.deb ... 136s Unpacking libwayland-client0:amd64 (1.23.1-3) ... 137s Selecting previously unselected package libxcb-shm0:amd64. 137s Preparing to unpack .../039-libxcb-shm0_1.17.0-2_amd64.deb ... 137s Unpacking libxcb-shm0:amd64 (1.17.0-2) ... 137s Selecting previously unselected package libegl-mesa0:amd64. 137s Preparing to unpack .../040-libegl-mesa0_25.0.3-1ubuntu2_amd64.deb ... 137s Unpacking libegl-mesa0:amd64 (25.0.3-1ubuntu2) ... 137s Selecting previously unselected package libfontenc1:amd64. 137s Preparing to unpack .../041-libfontenc1_1%3a1.1.8-1build1_amd64.deb ... 137s Unpacking libfontenc1:amd64 (1:1.1.8-1build1) ... 137s Selecting previously unselected package libvulkan1:amd64. 137s Preparing to unpack .../042-libvulkan1_1.4.309.0-1_amd64.deb ... 137s Unpacking libvulkan1:amd64 (1.4.309.0-1) ... 137s Selecting previously unselected package libgl1-mesa-dri:amd64. 137s Preparing to unpack .../043-libgl1-mesa-dri_25.0.3-1ubuntu2_amd64.deb ... 137s Unpacking libgl1-mesa-dri:amd64 (25.0.3-1ubuntu2) ... 137s Selecting previously unselected package libxcb-glx0:amd64. 137s Preparing to unpack .../044-libxcb-glx0_1.17.0-2_amd64.deb ... 137s Unpacking libxcb-glx0:amd64 (1.17.0-2) ... 137s Selecting previously unselected package libxxf86vm1:amd64. 137s Preparing to unpack .../045-libxxf86vm1_1%3a1.1.4-1build4_amd64.deb ... 137s Unpacking libxxf86vm1:amd64 (1:1.1.4-1build4) ... 137s Selecting previously unselected package libglx-mesa0:amd64. 137s Preparing to unpack .../046-libglx-mesa0_25.0.3-1ubuntu2_amd64.deb ... 137s Unpacking libglx-mesa0:amd64 (25.0.3-1ubuntu2) ... 137s Selecting previously unselected package libgomp1:amd64. 137s Preparing to unpack .../047-libgomp1_15.1.0-2ubuntu1_amd64.deb ... 137s Unpacking libgomp1:amd64 (15.1.0-2ubuntu1) ... 137s Selecting previously unselected package libgraphite2-3:amd64. 137s Preparing to unpack .../048-libgraphite2-3_1.3.14-2ubuntu1_amd64.deb ... 137s Unpacking libgraphite2-3:amd64 (1.3.14-2ubuntu1) ... 137s Selecting previously unselected package libharfbuzz0b:amd64. 137s Preparing to unpack .../049-libharfbuzz0b_10.2.0-1_amd64.deb ... 137s Unpacking libharfbuzz0b:amd64 (10.2.0-1) ... 137s Selecting previously unselected package libsz2:amd64. 137s Preparing to unpack .../050-libsz2_1.1.3-1_amd64.deb ... 137s Unpacking libsz2:amd64 (1.1.3-1) ... 137s Selecting previously unselected package libhdf5-310:amd64. 137s Preparing to unpack .../051-libhdf5-310_1.14.5+repack-3_amd64.deb ... 137s Unpacking libhdf5-310:amd64 (1.14.5+repack-3) ... 137s Selecting previously unselected package libice6:amd64. 137s Preparing to unpack .../052-libice6_2%3a1.1.1-1_amd64.deb ... 137s Unpacking libice6:amd64 (2:1.1.1-1) ... 137s Selecting previously unselected package libimagequant0:amd64. 137s Preparing to unpack .../053-libimagequant0_2.18.0-1build1_amd64.deb ... 137s Unpacking libimagequant0:amd64 (2.18.0-1build1) ... 137s Selecting previously unselected package libwacom-common. 137s Preparing to unpack .../054-libwacom-common_2.14.0-1_all.deb ... 137s Unpacking libwacom-common (2.14.0-1) ... 137s Selecting previously unselected package libwacom9:amd64. 137s Preparing to unpack .../055-libwacom9_2.14.0-1_amd64.deb ... 137s Unpacking libwacom9:amd64 (2.14.0-1) ... 137s Selecting previously unselected package libinput-bin. 137s Preparing to unpack .../056-libinput-bin_1.28.1-1_amd64.deb ... 137s Unpacking libinput-bin (1.28.1-1) ... 137s Selecting previously unselected package libmtdev1t64:amd64. 137s Preparing to unpack .../057-libmtdev1t64_1.1.7-1_amd64.deb ... 137s Unpacking libmtdev1t64:amd64 (1.1.7-1) ... 137s Selecting previously unselected package libinput10:amd64. 137s Preparing to unpack .../058-libinput10_1.28.1-1_amd64.deb ... 137s Unpacking libinput10:amd64 (1.28.1-1) ... 137s Selecting previously unselected package libjpeg-turbo8:amd64. 137s Preparing to unpack .../059-libjpeg-turbo8_2.1.5-3ubuntu2_amd64.deb ... 137s Unpacking libjpeg-turbo8:amd64 (2.1.5-3ubuntu2) ... 137s Selecting previously unselected package libjpeg8:amd64. 137s Preparing to unpack .../060-libjpeg8_8c-2ubuntu11_amd64.deb ... 137s Unpacking libjpeg8:amd64 (8c-2ubuntu11) ... 137s Selecting previously unselected package libjs-jquery. 137s Preparing to unpack .../061-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 137s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 138s Selecting previously unselected package libjs-jquery-ui. 138s Preparing to unpack .../062-libjs-jquery-ui_1.13.2+dfsg-1_all.deb ... 138s Unpacking libjs-jquery-ui (1.13.2+dfsg-1) ... 138s Selecting previously unselected package liblbfgsb0:amd64. 138s Preparing to unpack .../063-liblbfgsb0_3.0+dfsg.4-1build1_amd64.deb ... 138s Unpacking liblbfgsb0:amd64 (3.0+dfsg.4-1build1) ... 138s Selecting previously unselected package liblcms2-2:amd64. 138s Preparing to unpack .../064-liblcms2-2_2.16-2_amd64.deb ... 138s Unpacking liblcms2-2:amd64 (2.16-2) ... 138s Selecting previously unselected package liblerc4:amd64. 138s Preparing to unpack .../065-liblerc4_4.0.0+ds-5ubuntu1_amd64.deb ... 138s Unpacking liblerc4:amd64 (4.0.0+ds-5ubuntu1) ... 138s Selecting previously unselected package libmd4c0:amd64. 138s Preparing to unpack .../066-libmd4c0_0.5.2-2_amd64.deb ... 138s Unpacking libmd4c0:amd64 (0.5.2-2) ... 138s Selecting previously unselected package libpcre2-16-0:amd64. 138s Preparing to unpack .../067-libpcre2-16-0_10.45-1_amd64.deb ... 138s Unpacking libpcre2-16-0:amd64 (10.45-1) ... 138s Selecting previously unselected package libpixman-1-0:amd64. 138s Preparing to unpack .../068-libpixman-1-0_0.44.0-3_amd64.deb ... 138s Unpacking libpixman-1-0:amd64 (0.44.0-3) ... 138s Selecting previously unselected package libqhull-r8.0:amd64. 138s Preparing to unpack .../069-libqhull-r8.0_2020.2-6build1_amd64.deb ... 138s Unpacking libqhull-r8.0:amd64 (2020.2-6build1) ... 138s Selecting previously unselected package libqt5core5t64:amd64. 138s Preparing to unpack .../070-libqt5core5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 138s Unpacking libqt5core5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 138s Selecting previously unselected package libqt5dbus5t64:amd64. 138s Preparing to unpack .../071-libqt5dbus5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 138s Unpacking libqt5dbus5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 138s Selecting previously unselected package libglvnd0:amd64. 138s Preparing to unpack .../072-libglvnd0_1.7.0-1build1_amd64.deb ... 138s Unpacking libglvnd0:amd64 (1.7.0-1build1) ... 138s Selecting previously unselected package libegl1:amd64. 138s Preparing to unpack .../073-libegl1_1.7.0-1build1_amd64.deb ... 138s Unpacking libegl1:amd64 (1.7.0-1build1) ... 138s Selecting previously unselected package libglx0:amd64. 138s Preparing to unpack .../074-libglx0_1.7.0-1build1_amd64.deb ... 138s Unpacking libglx0:amd64 (1.7.0-1build1) ... 138s Selecting previously unselected package libgl1:amd64. 138s Preparing to unpack .../075-libgl1_1.7.0-1build1_amd64.deb ... 138s Unpacking libgl1:amd64 (1.7.0-1build1) ... 138s Selecting previously unselected package libqt5network5t64:amd64. 138s Preparing to unpack .../076-libqt5network5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 138s Unpacking libqt5network5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 138s Selecting previously unselected package libsm6:amd64. 138s Preparing to unpack .../077-libsm6_2%3a1.2.6-1_amd64.deb ... 138s Unpacking libsm6:amd64 (2:1.2.6-1) ... 138s Selecting previously unselected package libxcb-icccm4:amd64. 138s Preparing to unpack .../078-libxcb-icccm4_0.4.2-1_amd64.deb ... 138s Unpacking libxcb-icccm4:amd64 (0.4.2-1) ... 138s Selecting previously unselected package libxcb-util1:amd64. 138s Preparing to unpack .../079-libxcb-util1_0.4.1-1_amd64.deb ... 138s Unpacking libxcb-util1:amd64 (0.4.1-1) ... 138s Selecting previously unselected package libxcb-image0:amd64. 138s Preparing to unpack .../080-libxcb-image0_0.4.0-2build1_amd64.deb ... 138s Unpacking libxcb-image0:amd64 (0.4.0-2build1) ... 138s Selecting previously unselected package libxcb-keysyms1:amd64. 138s Preparing to unpack .../081-libxcb-keysyms1_0.4.1-1_amd64.deb ... 138s Unpacking libxcb-keysyms1:amd64 (0.4.1-1) ... 138s Selecting previously unselected package libxcb-render0:amd64. 138s Preparing to unpack .../082-libxcb-render0_1.17.0-2_amd64.deb ... 138s Unpacking libxcb-render0:amd64 (1.17.0-2) ... 138s Selecting previously unselected package libxcb-render-util0:amd64. 138s Preparing to unpack .../083-libxcb-render-util0_0.3.10-1_amd64.deb ... 138s Unpacking libxcb-render-util0:amd64 (0.3.10-1) ... 138s Selecting previously unselected package libxcb-shape0:amd64. 138s Preparing to unpack .../084-libxcb-shape0_1.17.0-2_amd64.deb ... 138s Unpacking libxcb-shape0:amd64 (1.17.0-2) ... 139s Selecting previously unselected package libxcb-xinerama0:amd64. 139s Preparing to unpack .../085-libxcb-xinerama0_1.17.0-2_amd64.deb ... 139s Unpacking libxcb-xinerama0:amd64 (1.17.0-2) ... 139s Selecting previously unselected package libxcb-xinput0:amd64. 139s Preparing to unpack .../086-libxcb-xinput0_1.17.0-2_amd64.deb ... 139s Unpacking libxcb-xinput0:amd64 (1.17.0-2) ... 139s Selecting previously unselected package libxcb-xkb1:amd64. 139s Preparing to unpack .../087-libxcb-xkb1_1.17.0-2_amd64.deb ... 139s Unpacking libxcb-xkb1:amd64 (1.17.0-2) ... 139s Selecting previously unselected package libxkbcommon-x11-0:amd64. 139s Preparing to unpack .../088-libxkbcommon-x11-0_1.7.0-2_amd64.deb ... 139s Unpacking libxkbcommon-x11-0:amd64 (1.7.0-2) ... 139s Selecting previously unselected package libqt5gui5t64:amd64. 139s Preparing to unpack .../089-libqt5gui5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 139s Unpacking libqt5gui5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 139s Selecting previously unselected package libqt5widgets5t64:amd64. 139s Preparing to unpack .../090-libqt5widgets5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 139s Unpacking libqt5widgets5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 139s Selecting previously unselected package libqt5xml5t64:amd64. 139s Preparing to unpack .../091-libqt5xml5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 139s Unpacking libqt5xml5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 139s Selecting previously unselected package libqt5designer5:amd64. 139s Preparing to unpack .../092-libqt5designer5_5.15.15-6build1_amd64.deb ... 139s Unpacking libqt5designer5:amd64 (5.15.15-6build1) ... 139s Selecting previously unselected package libqt5sql5t64:amd64. 139s Preparing to unpack .../093-libqt5sql5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 139s Unpacking libqt5sql5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 139s Selecting previously unselected package libqt5help5:amd64. 139s Preparing to unpack .../094-libqt5help5_5.15.15-6build1_amd64.deb ... 139s Unpacking libqt5help5:amd64 (5.15.15-6build1) ... 139s Selecting previously unselected package libqt5printsupport5t64:amd64. 139s Preparing to unpack .../095-libqt5printsupport5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 139s Unpacking libqt5printsupport5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 139s Selecting previously unselected package libqt5test5t64:amd64. 139s Preparing to unpack .../096-libqt5test5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 139s Unpacking libqt5test5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 139s Selecting previously unselected package libraqm0:amd64. 139s Preparing to unpack .../097-libraqm0_0.10.2-1_amd64.deb ... 139s Unpacking libraqm0:amd64 (0.10.2-1) ... 139s Selecting previously unselected package libsharpyuv0:amd64. 139s Preparing to unpack .../098-libsharpyuv0_1.5.0-0.1_amd64.deb ... 139s Unpacking libsharpyuv0:amd64 (1.5.0-0.1) ... 139s Selecting previously unselected package libjbig0:amd64. 139s Preparing to unpack .../099-libjbig0_2.1-6.1ubuntu2_amd64.deb ... 139s Unpacking libjbig0:amd64 (2.1-6.1ubuntu2) ... 139s Selecting previously unselected package libwebp7:amd64. 139s Preparing to unpack .../100-libwebp7_1.5.0-0.1_amd64.deb ... 139s Unpacking libwebp7:amd64 (1.5.0-0.1) ... 139s Selecting previously unselected package libtiff6:amd64. 139s Preparing to unpack .../101-libtiff6_4.7.0-3ubuntu1_amd64.deb ... 139s Unpacking libtiff6:amd64 (4.7.0-3ubuntu1) ... 139s Selecting previously unselected package libwebpdemux2:amd64. 139s Preparing to unpack .../102-libwebpdemux2_1.5.0-0.1_amd64.deb ... 139s Unpacking libwebpdemux2:amd64 (1.5.0-0.1) ... 139s Selecting previously unselected package libwebpmux3:amd64. 139s Preparing to unpack .../103-libwebpmux3_1.5.0-0.1_amd64.deb ... 139s Unpacking libwebpmux3:amd64 (1.5.0-0.1) ... 139s Selecting previously unselected package libxt6t64:amd64. 140s Preparing to unpack .../104-libxt6t64_1%3a1.2.1-1.2build1_amd64.deb ... 140s Unpacking libxt6t64:amd64 (1:1.2.1-1.2build1) ... 140s Selecting previously unselected package libxmu6:amd64. 140s Preparing to unpack .../105-libxmu6_2%3a1.1.3-3build2_amd64.deb ... 140s Unpacking libxmu6:amd64 (2:1.1.3-3build2) ... 140s Selecting previously unselected package libxpm4:amd64. 140s Preparing to unpack .../106-libxpm4_1%3a3.5.17-1build2_amd64.deb ... 140s Unpacking libxpm4:amd64 (1:3.5.17-1build2) ... 140s Selecting previously unselected package libxaw7:amd64. 140s Preparing to unpack .../107-libxaw7_2%3a1.0.16-1_amd64.deb ... 140s Unpacking libxaw7:amd64 (2:1.0.16-1) ... 140s Selecting previously unselected package libxfont2:amd64. 140s Preparing to unpack .../108-libxfont2_1%3a2.0.6-1build1_amd64.deb ... 140s Unpacking libxfont2:amd64 (1:2.0.6-1build1) ... 140s Selecting previously unselected package libxkbfile1:amd64. 140s Preparing to unpack .../109-libxkbfile1_1%3a1.1.0-1build4_amd64.deb ... 140s Unpacking libxkbfile1:amd64 (1:1.1.0-1build4) ... 140s Selecting previously unselected package libxrandr2:amd64. 140s Preparing to unpack .../110-libxrandr2_2%3a1.5.4-1_amd64.deb ... 140s Unpacking libxrandr2:amd64 (2:1.5.4-1) ... 140s Selecting previously unselected package libxslt1.1:amd64. 140s Preparing to unpack .../111-libxslt1.1_1.1.39-0exp1ubuntu4_amd64.deb ... 140s Unpacking libxslt1.1:amd64 (1.1.39-0exp1ubuntu4) ... 140s Selecting previously unselected package libzopfli1. 140s Preparing to unpack .../112-libzopfli1_1.0.3-3_amd64.deb ... 140s Unpacking libzopfli1 (1.0.3-3) ... 140s Selecting previously unselected package python-matplotlib-data. 140s Preparing to unpack .../113-python-matplotlib-data_3.10.1+dfsg1-3_all.deb ... 140s Unpacking python-matplotlib-data (3.10.1+dfsg1-3) ... 140s Selecting previously unselected package python-tables-data. 140s Preparing to unpack .../114-python-tables-data_3.10.2-2build1_all.deb ... 140s Unpacking python-tables-data (3.10.2-2build1) ... 140s Selecting previously unselected package python3-all. 140s Preparing to unpack .../115-python3-all_3.13.3-1_amd64.deb ... 140s Unpacking python3-all (3.13.3-1) ... 140s Selecting previously unselected package python3-async-generator. 140s Preparing to unpack .../116-python3-async-generator_1.10-4_all.deb ... 140s Unpacking python3-async-generator (1.10-4) ... 140s Selecting previously unselected package python3-bottleneck. 140s Preparing to unpack .../117-python3-bottleneck_1.4.2+ds1-2build1_amd64.deb ... 140s Unpacking python3-bottleneck (1.4.2+ds1-2build1) ... 140s Selecting previously unselected package python3-brotli. 140s Preparing to unpack .../118-python3-brotli_1.1.0-2build4_amd64.deb ... 140s Unpacking python3-brotli (1.1.0-2build4) ... 140s Selecting previously unselected package python3-soupsieve. 140s Preparing to unpack .../119-python3-soupsieve_2.7-1_all.deb ... 140s Unpacking python3-soupsieve (2.7-1) ... 140s Selecting previously unselected package python3-bs4. 140s Preparing to unpack .../120-python3-bs4_4.13.4-1_all.deb ... 140s Unpacking python3-bs4 (4.13.4-1) ... 140s Selecting previously unselected package python3-click. 140s Preparing to unpack .../121-python3-click_8.2.0+0.really.8.1.8-1_all.deb ... 140s Unpacking python3-click (8.2.0+0.really.8.1.8-1) ... 140s Selecting previously unselected package python3-cloudpickle. 140s Preparing to unpack .../122-python3-cloudpickle_3.1.1-1_all.deb ... 140s Unpacking python3-cloudpickle (3.1.1-1) ... 140s Selecting previously unselected package python3-contourpy. 140s Preparing to unpack .../123-python3-contourpy_1.3.1-1build1_amd64.deb ... 140s Unpacking python3-contourpy (1.3.1-1build1) ... 140s Selecting previously unselected package python3-cpuinfo. 140s Preparing to unpack .../124-python3-cpuinfo_9.0.0+git20221119-3_all.deb ... 140s Unpacking python3-cpuinfo (9.0.0+git20221119-3) ... 140s Selecting previously unselected package python3-cycler. 140s Preparing to unpack .../125-python3-cycler_0.12.1-1_all.deb ... 140s Unpacking python3-cycler (0.12.1-1) ... 140s Selecting previously unselected package python3-fsspec. 140s Preparing to unpack .../126-python3-fsspec_2025.3.2-1_all.deb ... 140s Unpacking python3-fsspec (2025.3.2-1) ... 141s Selecting previously unselected package python3-toolz. 141s Preparing to unpack .../127-python3-toolz_1.0.0-2_all.deb ... 141s Unpacking python3-toolz (1.0.0-2) ... 141s Selecting previously unselected package python3-locket. 141s Preparing to unpack .../128-python3-locket_1.0.0-2_all.deb ... 141s Unpacking python3-locket (1.0.0-2) ... 141s Selecting previously unselected package python3-partd. 141s Preparing to unpack .../129-python3-partd_1.4.2-1_all.deb ... 141s Unpacking python3-partd (1.4.2-1) ... 141s Selecting previously unselected package python3-dask. 141s Preparing to unpack .../130-python3-dask_2024.12.1+dfsg-2_all.deb ... 141s Unpacking python3-dask (2024.12.1+dfsg-2) ... 141s Selecting previously unselected package python3-decorator. 141s Preparing to unpack .../131-python3-decorator_5.2.1-2_all.deb ... 141s Unpacking python3-decorator (5.2.1-2) ... 141s Selecting previously unselected package python3-defusedxml. 141s Preparing to unpack .../132-python3-defusedxml_0.7.1-3_all.deb ... 141s Unpacking python3-defusedxml (0.7.1-3) ... 141s Selecting previously unselected package python3-et-xmlfile. 141s Preparing to unpack .../133-python3-et-xmlfile_2.0.0-1_all.deb ... 141s Unpacking python3-et-xmlfile (2.0.0-1) ... 141s Selecting previously unselected package python3-execnet. 141s Preparing to unpack .../134-python3-execnet_2.1.1-1_all.deb ... 141s Unpacking python3-execnet (2.1.1-1) ... 141s Selecting previously unselected package python3-platformdirs. 141s Preparing to unpack .../135-python3-platformdirs_4.3.7-1_all.deb ... 141s Unpacking python3-platformdirs (4.3.7-1) ... 141s Selecting previously unselected package python3-fs. 141s Preparing to unpack .../136-python3-fs_2.4.16-7_all.deb ... 141s Unpacking python3-fs (2.4.16-7) ... 141s Selecting previously unselected package python3-lxml:amd64. 141s Preparing to unpack .../137-python3-lxml_5.3.2-1_amd64.deb ... 141s Unpacking python3-lxml:amd64 (5.3.2-1) ... 141s Selecting previously unselected package python3-lz4. 141s Preparing to unpack .../138-python3-lz4_4.4.0+dfsg-2_amd64.deb ... 141s Unpacking python3-lz4 (4.4.0+dfsg-2) ... 141s Selecting previously unselected package python3-scipy. 141s Preparing to unpack .../139-python3-scipy_1.14.1-4ubuntu2_amd64.deb ... 141s Unpacking python3-scipy (1.14.1-4ubuntu2) ... 142s Selecting previously unselected package python3-mpmath. 142s Preparing to unpack .../140-python3-mpmath_1.3.0-1_all.deb ... 142s Unpacking python3-mpmath (1.3.0-1) ... 142s Selecting previously unselected package python3-sympy. 142s Preparing to unpack .../141-python3-sympy_1.13.3-5_all.deb ... 142s Unpacking python3-sympy (1.13.3-5) ... 142s Selecting previously unselected package python3-ufolib2. 142s Preparing to unpack .../142-python3-ufolib2_0.17.1+dfsg1-1_all.deb ... 142s Unpacking python3-ufolib2 (0.17.1+dfsg1-1) ... 142s Selecting previously unselected package python3-zopfli. 142s Preparing to unpack .../143-python3-zopfli_0.2.3.post1-1_amd64.deb ... 142s Unpacking python3-zopfli (0.2.3.post1-1) ... 142s Selecting previously unselected package unicode-data. 142s Preparing to unpack .../144-unicode-data_15.1.0-1_all.deb ... 142s Unpacking unicode-data (15.1.0-1) ... 142s Selecting previously unselected package python3-fonttools. 142s Preparing to unpack .../145-python3-fonttools_4.57.0-1_amd64.deb ... 142s Unpacking python3-fonttools (4.57.0-1) ... 142s Selecting previously unselected package python3-webencodings. 142s Preparing to unpack .../146-python3-webencodings_0.5.1-5_all.deb ... 142s Unpacking python3-webencodings (0.5.1-5) ... 142s Selecting previously unselected package python3-html5lib. 142s Preparing to unpack .../147-python3-html5lib_1.2-2_all.deb ... 142s Unpacking python3-html5lib (1.2-2) ... 142s Selecting previously unselected package python3-sortedcontainers. 142s Preparing to unpack .../148-python3-sortedcontainers_2.4.0-2_all.deb ... 142s Unpacking python3-sortedcontainers (2.4.0-2) ... 143s Selecting previously unselected package python3-hypothesis. 143s Preparing to unpack .../149-python3-hypothesis_6.130.5-1_all.deb ... 143s Unpacking python3-hypothesis (6.130.5-1) ... 143s Selecting previously unselected package python3-iniconfig. 143s Preparing to unpack .../150-python3-iniconfig_1.1.1-2_all.deb ... 143s Unpacking python3-iniconfig (1.1.1-2) ... 143s Selecting previously unselected package python3-kiwisolver. 143s Preparing to unpack .../151-python3-kiwisolver_1.4.7-3build1_amd64.deb ... 143s Unpacking python3-kiwisolver (1.4.7-3build1) ... 143s Selecting previously unselected package libopenjp2-7:amd64. 143s Preparing to unpack .../152-libopenjp2-7_2.5.3-2_amd64.deb ... 143s Unpacking libopenjp2-7:amd64 (2.5.3-2) ... 143s Selecting previously unselected package python3-pil:amd64. 143s Preparing to unpack .../153-python3-pil_11.1.0-5build1_amd64.deb ... 143s Unpacking python3-pil:amd64 (11.1.0-5build1) ... 143s Selecting previously unselected package python3.13-tk. 143s Preparing to unpack .../154-python3.13-tk_3.13.3-2_amd64.deb ... 143s Unpacking python3.13-tk (3.13.3-2) ... 143s Selecting previously unselected package python3-tk:amd64. 143s Preparing to unpack .../155-python3-tk_3.13.3-1_amd64.deb ... 143s Unpacking python3-tk:amd64 (3.13.3-1) ... 143s Selecting previously unselected package python3-pil.imagetk:amd64. 143s Preparing to unpack .../156-python3-pil.imagetk_11.1.0-5build1_amd64.deb ... 143s Unpacking python3-pil.imagetk:amd64 (11.1.0-5build1) ... 143s Selecting previously unselected package python3-matplotlib. 143s Preparing to unpack .../157-python3-matplotlib_3.10.1+dfsg1-3_amd64.deb ... 143s Unpacking python3-matplotlib (3.10.1+dfsg1-3) ... 143s Selecting previously unselected package python3-numexpr. 143s Preparing to unpack .../158-python3-numexpr_2.10.2-1build2_amd64.deb ... 143s Unpacking python3-numexpr (2.10.2-1build2) ... 144s Selecting previously unselected package python3-odf. 144s Preparing to unpack .../159-python3-odf_1.4.2-4_all.deb ... 144s Unpacking python3-odf (1.4.2-4) ... 144s Selecting previously unselected package python3-openpyxl. 144s Preparing to unpack .../160-python3-openpyxl_3.1.5+dfsg-2_all.deb ... 144s Unpacking python3-openpyxl (3.1.5+dfsg-2) ... 144s Selecting previously unselected package python3-pluggy. 144s Preparing to unpack .../161-python3-pluggy_1.5.0-1_all.deb ... 144s Unpacking python3-pluggy (1.5.0-1) ... 144s Selecting previously unselected package python3-py. 144s Preparing to unpack .../162-python3-py_1.11.0-4_all.deb ... 144s Unpacking python3-py (1.11.0-4) ... 144s Selecting previously unselected package python3-pyqt5.sip. 144s Preparing to unpack .../163-python3-pyqt5.sip_12.17.0-1build1_amd64.deb ... 144s Unpacking python3-pyqt5.sip (12.17.0-1build1) ... 144s Selecting previously unselected package python3-pyqt5. 144s Preparing to unpack .../164-python3-pyqt5_5.15.11+dfsg-2_amd64.deb ... 144s Unpacking python3-pyqt5 (5.15.11+dfsg-2) ... 144s Selecting previously unselected package python3-pyreadstat. 144s Preparing to unpack .../165-python3-pyreadstat_1.2.8-1build1_amd64.deb ... 144s Unpacking python3-pyreadstat (1.2.8-1build1) ... 144s Selecting previously unselected package python3-pytest. 144s Preparing to unpack .../166-python3-pytest_8.3.5-2_all.deb ... 144s Unpacking python3-pytest (8.3.5-2) ... 144s Selecting previously unselected package python3-pytest-asyncio. 144s Preparing to unpack .../167-python3-pytest-asyncio_0.25.1-1_all.deb ... 144s Unpacking python3-pytest-asyncio (0.25.1-1) ... 144s Selecting previously unselected package python3-pytest-forked. 144s Preparing to unpack .../168-python3-pytest-forked_1.6.0-3_all.deb ... 144s Unpacking python3-pytest-forked (1.6.0-3) ... 144s Selecting previously unselected package python3-werkzeug. 144s Preparing to unpack .../169-python3-werkzeug_3.1.3-2_all.deb ... 144s Unpacking python3-werkzeug (3.1.3-2) ... 144s Selecting previously unselected package python3-pytest-localserver. 144s Preparing to unpack .../170-python3-pytest-localserver_0.9.0.post0-1_all.deb ... 144s Unpacking python3-pytest-localserver (0.9.0.post0-1) ... 144s Selecting previously unselected package python3-pytest-xdist. 144s Preparing to unpack .../171-python3-pytest-xdist_3.6.1-1_all.deb ... 144s Unpacking python3-pytest-xdist (3.6.1-1) ... 144s Selecting previously unselected package python3-pytestqt. 144s Preparing to unpack .../172-python3-pytestqt_4.4.0-1_all.deb ... 144s Unpacking python3-pytestqt (4.4.0-1) ... 144s Preparing to unpack .../173-python3-pytz_2025.2-2_all.deb ... 144s Unpacking python3-pytz (2025.2-2) over (2025.1-3) ... 145s Selecting previously unselected package python3-greenlet. 145s Preparing to unpack .../174-python3-greenlet_3.1.0-1build1_amd64.deb ... 145s Unpacking python3-greenlet (3.1.0-1build1) ... 145s Selecting previously unselected package python3-sqlalchemy. 145s Preparing to unpack .../175-python3-sqlalchemy_2.0.38+ds1-0ubuntu2_all.deb ... 145s Unpacking python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 145s Selecting previously unselected package python3-tables-lib. 145s Preparing to unpack .../176-python3-tables-lib_3.10.2-2build1_amd64.deb ... 145s Unpacking python3-tables-lib (3.10.2-2build1) ... 145s Selecting previously unselected package python3-tables. 145s Preparing to unpack .../177-python3-tables_3.10.2-2build1_all.deb ... 145s Unpacking python3-tables (3.10.2-2build1) ... 145s Selecting previously unselected package python3-tabulate. 145s Preparing to unpack .../178-python3-tabulate_0.9.0-1_all.deb ... 145s Unpacking python3-tabulate (0.9.0-1) ... 145s Selecting previously unselected package python3-tz. 145s Preparing to unpack .../179-python3-tz_2025.2-2_all.deb ... 145s Unpacking python3-tz (2025.2-2) ... 145s Selecting previously unselected package python3-xarray. 145s Preparing to unpack .../180-python3-xarray_2025.03.1-4_all.deb ... 145s Unpacking python3-xarray (2025.03.1-4) ... 145s Selecting previously unselected package python3-xlrd. 145s Preparing to unpack .../181-python3-xlrd_2.0.1-2_all.deb ... 145s Unpacking python3-xlrd (2.0.1-2) ... 145s Selecting previously unselected package python3-xlsxwriter. 145s Preparing to unpack .../182-python3-xlsxwriter_3.1.9-2_all.deb ... 145s Unpacking python3-xlsxwriter (3.1.9-2) ... 145s Selecting previously unselected package python3-zstandard. 145s Preparing to unpack .../183-python3-zstandard_0.23.0-4_amd64.deb ... 145s Unpacking python3-zstandard (0.23.0-4) ... 145s Preparing to unpack .../184-python3.13-gdbm_3.13.3-2_amd64.deb ... 145s Unpacking python3.13-gdbm (3.13.3-2) over (3.13.3-1) ... 145s Selecting previously unselected package tzdata-legacy. 145s Preparing to unpack .../185-tzdata-legacy_2025b-3ubuntu1_all.deb ... 145s Unpacking tzdata-legacy (2025b-3ubuntu1) ... 145s Selecting previously unselected package x11-xkb-utils. 145s Preparing to unpack .../186-x11-xkb-utils_7.7+9_amd64.deb ... 145s Unpacking x11-xkb-utils (7.7+9) ... 145s Selecting previously unselected package xsel. 145s Preparing to unpack .../187-xsel_1.2.1-1_amd64.deb ... 145s Unpacking xsel (1.2.1-1) ... 145s Selecting previously unselected package xserver-common. 145s Preparing to unpack .../188-xserver-common_2%3a21.1.16-1ubuntu1_all.deb ... 145s Unpacking xserver-common (2:21.1.16-1ubuntu1) ... 146s Selecting previously unselected package xvfb. 146s Preparing to unpack .../189-xvfb_2%3a21.1.16-1ubuntu1_amd64.deb ... 146s Unpacking xvfb (2:21.1.16-1ubuntu1) ... 146s Preparing to unpack .../190-zstd_1.5.7+dfsg-1_amd64.deb ... 146s Unpacking zstd (1.5.7+dfsg-1) over (1.5.6+dfsg-2) ... 146s Selecting previously unselected package locales-all. 146s Preparing to unpack .../191-locales-all_2.41-6ubuntu1_amd64.deb ... 146s Unpacking locales-all (2.41-6ubuntu1) ... 147s Setting up libgraphite2-3:amd64 (1.3.14-2ubuntu1) ... 147s Setting up libxcb-dri3-0:amd64 (1.17.0-2) ... 147s Setting up liblcms2-2:amd64 (2.16-2) ... 147s Setting up python3-iniconfig (1.1.1-2) ... 147s Setting up libpixman-1-0:amd64 (0.44.0-3) ... 147s Setting up libsharpyuv0:amd64 (1.5.0-0.1) ... 147s Setting up libwayland-server0:amd64 (1.23.1-3) ... 147s Setting up libpciaccess0:amd64 (0.17-3build1) ... 147s Setting up libdouble-conversion3:amd64 (3.3.1-1) ... 147s Setting up libxcb-xfixes0:amd64 (1.17.0-2) ... 147s Setting up liblerc4:amd64 (4.0.0+ds-5ubuntu1) ... 147s Setting up python3-async-generator (1.10-4) ... 147s Setting up libxcb-xinput0:amd64 (1.17.0-2) ... 147s Setting up python3-py (1.11.0-4) ... 148s Setting up python3-lz4 (4.4.0+dfsg-2) ... 148s Setting up libxcb-render0:amd64 (1.17.0-2) ... 148s Setting up python3-defusedxml (0.7.1-3) ... 148s Setting up libglvnd0:amd64 (1.7.0-1build1) ... 148s Setting up fonts-lyx (2.4.3-1) ... 148s Setting up libxcb-glx0:amd64 (1.17.0-2) ... 148s Setting up python3-fsspec (2025.3.2-1) ... 148s Setting up python3-xarray (2025.03.1-4) ... 150s Setting up libdrm-intel1:amd64 (2.4.124-2) ... 150s Setting up libxcb-keysyms1:amd64 (0.4.1-1) ... 150s Setting up libxcb-shape0:amd64 (1.17.0-2) ... 150s Setting up x11-common (1:7.7+23ubuntu4) ... 150s Setting up libdeflate0:amd64 (1.23-2) ... 150s Setting up python3-tabulate (0.9.0-1) ... 150s Setting up libqhull-r8.0:amd64 (2020.2-6build1) ... 150s Setting up libxcb-render-util0:amd64 (0.3.10-1) ... 150s Setting up libxcb-shm0:amd64 (1.17.0-2) ... 150s Setting up libxcb-icccm4:amd64 (0.4.2-1) ... 150s Setting up python3-sortedcontainers (2.4.0-2) ... 151s Setting up libgomp1:amd64 (15.1.0-2ubuntu1) ... 151s Setting up python3-click (8.2.0+0.really.8.1.8-1) ... 151s Setting up libjbig0:amd64 (2.1-6.1ubuntu2) ... 151s Setting up python3-webencodings (0.5.1-5) ... 151s Setting up python3-pyreadstat (1.2.8-1build1) ... 151s Setting up locales-all (2.41-6ubuntu1) ... 151s Setting up libpcre2-16-0:amd64 (10.45-1) ... 151s Setting up libaec0:amd64 (1.1.3-1) ... 151s Setting up python3-platformdirs (4.3.7-1) ... 151s Setting up libxcb-util1:amd64 (0.4.1-1) ... 151s Setting up python3-cloudpickle (3.1.1-1) ... 151s Setting up libsnappy1v5:amd64 (1.2.2-1) ... 151s Setting up libxcb-xkb1:amd64 (1.17.0-2) ... 151s Setting up libxcb-image0:amd64 (0.4.0-2build1) ... 151s Setting up python3-fs (2.4.16-7) ... 152s Setting up tzdata (2025b-3ubuntu1) ... 152s 152s Current default time zone: 'Etc/UTC' 152s Local time is now: Sat May 3 20:03:04 UTC 2025. 152s Universal Time is now: Sat May 3 20:03:04 UTC 2025. 152s Run 'dpkg-reconfigure tzdata' if you wish to change it. 152s 152s Setting up libxcb-present0:amd64 (1.17.0-2) ... 152s Setting up unicode-data (15.1.0-1) ... 152s Setting up libpython3.13-minimal:amd64 (3.13.3-2) ... 152s Setting up libqt5core5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 152s Setting up python3-decorator (5.2.1-2) ... 152s Setting up libblosc2-4:amd64 (2.17.1+ds-1) ... 152s Setting up libfontenc1:amd64 (1:1.1.8-1build1) ... 152s Setting up python3-zstandard (0.23.0-4) ... 152s Setting up libxcb-xinerama0:amd64 (1.17.0-2) ... 152s Setting up python3-xlsxwriter (3.1.9-2) ... 152s Setting up libzopfli1 (1.0.3-3) ... 152s Setting up libx11-data (2:1.8.12-1) ... 152s Setting up libxcb-sync1:amd64 (1.17.0-2) ... 152s Setting up python3-werkzeug (3.1.3-2) ... 153s Setting up python3-brotli (1.1.0-2build4) ... 153s Setting up libavahi-common-data:amd64 (0.8-16ubuntu2) ... 153s Setting up python3-greenlet (3.1.0-1build1) ... 153s Setting up python3-cycler (0.12.1-1) ... 153s Setting up libimagequant0:amd64 (2.18.0-1build1) ... 153s Setting up libxkbcommon-x11-0:amd64 (1.7.0-2) ... 153s Setting up fonts-dejavu-mono (2.37-8) ... 153s Setting up python3-kiwisolver (1.4.7-3build1) ... 153s Setting up python3-bottleneck (1.4.2+ds1-2build1) ... 153s Setting up libatomic1:amd64 (15.1.0-2ubuntu1) ... 153s Setting up libtcl8.6:amd64 (8.6.16+dfsg-1) ... 153s Setting up fonts-dejavu-core (2.37-8) ... 153s Setting up python3-numexpr (2.10.2-1build2) ... 154s Setting up libjpeg-turbo8:amd64 (2.1.5-3ubuntu2) ... 154s Setting up python3-cpuinfo (9.0.0+git20221119-3) ... 154s Setting up python3-html5lib (1.2-2) ... 154s Setting up libgfortran5:amd64 (15.1.0-2ubuntu1) ... 154s Setting up libvulkan1:amd64 (1.4.309.0-1) ... 154s Setting up python3-pluggy (1.5.0-1) ... 154s Setting up libwebp7:amd64 (1.5.0-0.1) ... 154s Setting up python3-pyqt5.sip (12.17.0-1build1) ... 154s Setting up libmtdev1t64:amd64 (1.1.7-1) ... 154s Setting up libxshmfence1:amd64 (1.3.3-1) ... 154s Setting up libxcb-randr0:amd64 (1.17.0-2) ... 154s Setting up libxslt1.1:amd64 (1.1.39-0exp1ubuntu4) ... 154s Setting up libblosc1:amd64 (1.21.5+ds-1build1) ... 154s Setting up python3-et-xmlfile (2.0.0-1) ... 154s Setting up libqt5sql5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 154s Setting up libmd4c0:amd64 (0.5.2-2) ... 154s Setting up python3-xlrd (2.0.1-2) ... 155s Setting up libopenjp2-7:amd64 (2.5.3-2) ... 155s Setting up python3.13-minimal (3.13.3-2) ... 155s Setting up python3-toolz (1.0.0-2) ... 156s Setting up libx11-6:amd64 (2:1.8.12-1) ... 156s Setting up libharfbuzz0b:amd64 (10.2.0-1) ... 156s Setting up python3-contourpy (1.3.1-1build1) ... 156s Setting up libxss1:amd64 (1:1.2.3-1build3) ... 156s Setting up libxkbfile1:amd64 (1:1.1.0-1build4) ... 156s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 156s Setting up python3-mpmath (1.3.0-1) ... 156s Setting up python3-execnet (2.1.1-1) ... 157s Setting up python-matplotlib-data (3.10.1+dfsg1-3) ... 157s Setting up libwebpmux3:amd64 (1.5.0-0.1) ... 157s Setting up python3-locket (1.0.0-2) ... 157s Setting up libxfont2:amd64 (1:2.0.6-1build1) ... 157s Setting up libpython3.13-stdlib:amd64 (3.13.3-2) ... 157s Setting up python3-soupsieve (2.7-1) ... 157s Setting up python-tables-data (3.10.2-2build1) ... 157s Setting up zstd (1.5.7+dfsg-1) ... 157s Setting up libsz2:amd64 (1.1.3-1) ... 157s Setting up python3.13-gdbm (3.13.3-2) ... 157s Setting up liblbfgsb0:amd64 (3.0+dfsg.4-1build1) ... 157s Setting up python3-odf (1.4.2-4) ... 157s Setting up libwacom-common (2.14.0-1) ... 157s Setting up libwayland-client0:amd64 (1.23.1-3) ... 157s Setting up libpython3.13:amd64 (3.13.3-2) ... 157s Setting up libjpeg8:amd64 (8c-2ubuntu11) ... 157s Setting up python3-partd (1.4.2-1) ... 158s Setting up xsel (1.2.1-1) ... 158s Setting up python3-sympy (1.13.3-5) ... 165s Setting up libx11-xcb1:amd64 (2:1.8.12-1) ... 165s Setting up libice6:amd64 (2:1.1.1-1) ... 165s Setting up mesa-libgallium:amd64 (25.0.3-1ubuntu2) ... 165s Setting up libqt5dbus5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 165s Setting up python3-scipy (1.14.1-4ubuntu2) ... 169s Setting up libxpm4:amd64 (1:3.5.17-1build2) ... 169s Setting up libxrender1:amd64 (1:0.9.12-1) ... 169s Setting up libgbm1:amd64 (25.0.3-1ubuntu2) ... 169s Setting up python3.13 (3.13.3-2) ... 170s Setting up libwacom9:amd64 (2.14.0-1) ... 170s Setting up fontconfig-config (2.15.0-2.2ubuntu1) ... 170s Setting up python3-pytest (8.3.5-2) ... 170s Setting up python3-pytest-localserver (0.9.0.post0-1) ... 170s Setting up libwebpdemux2:amd64 (1.5.0-0.1) ... 170s Setting up python3-hypothesis (6.130.5-1) ... 171s Setting up libgl1-mesa-dri:amd64 (25.0.3-1ubuntu2) ... 171s Setting up libqt5network5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 171s Setting up libavahi-common3:amd64 (0.8-16ubuntu2) ... 171s Setting up python3-dask (2024.12.1+dfsg-2) ... 172s Setting up libqt5xml5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 172s Setting up python3-all (3.13.3-1) ... 172s Setting up python3-pytz (2025.2-2) ... 172s Setting up libqt5test5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 172s Setting up tzdata-legacy (2025b-3ubuntu1) ... 172s Setting up python3-tz (2025.2-2) ... 172s Setting up python3-bs4 (4.13.4-1) ... 173s Setting up python3-zopfli (0.2.3.post1-1) ... 173s Setting up python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 175s Setting up libxxf86vm1:amd64 (1:1.1.4-1build4) ... 175s Setting up libinput-bin (1.28.1-1) ... 175s Setting up python3-pytest-forked (1.6.0-3) ... 175s Setting up libegl-mesa0:amd64 (25.0.3-1ubuntu2) ... 175s Setting up libjs-jquery-ui (1.13.2+dfsg-1) ... 175s Setting up libraqm0:amd64 (0.10.2-1) ... 175s Setting up libxrandr2:amd64 (2:1.5.4-1) ... 175s Setting up python3-pytest-asyncio (0.25.1-1) ... 175s Setting up libhdf5-310:amd64 (1.14.5+repack-3) ... 175s Setting up python3-lxml:amd64 (5.3.2-1) ... 175s Setting up libtiff6:amd64 (4.7.0-3ubuntu1) ... 175s Setting up libegl1:amd64 (1.7.0-1build1) ... 175s Setting up libfontconfig1:amd64 (2.15.0-2.2ubuntu1) ... 175s Setting up libsm6:amd64 (2:1.2.6-1) ... 175s Setting up python3-pytestqt (4.4.0-1) ... 175s Setting up libavahi-client3:amd64 (0.8-16ubuntu2) ... 175s Setting up libinput10:amd64 (1.28.1-1) ... 175s Setting up fontconfig (2.15.0-2.2ubuntu1) ... 177s Regenerating fonts cache... done. 177s Setting up libxft2:amd64 (2.3.6-1build1) ... 177s Setting up libglx-mesa0:amd64 (25.0.3-1ubuntu2) ... 177s Setting up python3-pytest-xdist (3.6.1-1) ... 178s Setting up libglx0:amd64 (1.7.0-1build1) ... 178s Setting up python3-tables-lib (3.10.2-2build1) ... 178s Setting up libtk8.6:amd64 (8.6.16-1) ... 178s Setting up python3-tables (3.10.2-2build1) ... 178s Setting up python3.13-tk (3.13.3-2) ... 178s Setting up python3-pil:amd64 (11.1.0-5build1) ... 179s Setting up libgl1:amd64 (1.7.0-1build1) ... 179s Setting up python3-openpyxl (3.1.5+dfsg-2) ... 179s Setting up libxt6t64:amd64 (1:1.2.1-1.2build1) ... 179s Setting up libcups2t64:amd64 (2.4.12-0ubuntu1) ... 179s Setting up tk8.6-blt2.5 (2.5.3+dfsg-8) ... 179s Setting up libxmu6:amd64 (2:1.1.3-3build2) ... 179s Setting up blt (2.5.3+dfsg-8) ... 179s Setting up python3-tk:amd64 (3.13.3-1) ... 179s Setting up libxaw7:amd64 (2:1.0.16-1) ... 179s Setting up libqt5gui5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 179s Setting up python3-pil.imagetk:amd64 (11.1.0-5build1) ... 179s Setting up libqt5widgets5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 179s Setting up x11-xkb-utils (7.7+9) ... 179s Setting up libqt5help5:amd64 (5.15.15-6build1) ... 179s Setting up xserver-common (2:21.1.16-1ubuntu1) ... 179s Setting up libqt5printsupport5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 180s Setting up libqt5designer5:amd64 (5.15.15-6build1) ... 180s Setting up xvfb (2:21.1.16-1ubuntu1) ... 180s Setting up python3-pyqt5 (5.15.11+dfsg-2) ... 180s Setting up python3-ufolib2 (0.17.1+dfsg1-1) ... 180s Setting up python3-fonttools (4.57.0-1) ... 181s Setting up python3-matplotlib (3.10.1+dfsg1-3) ... 182s Processing triggers for libc-bin (2.41-6ubuntu1) ... 182s Processing triggers for systemd (257.4-1ubuntu3) ... 183s Processing triggers for man-db (2.13.0-1) ... 183s Processing triggers for udev (257.4-1ubuntu3) ... 185s autopkgtest [20:03:37]: testbed environment configured for cross-architecture building 185s autopkgtest [20:03:37]: test unittests3: [----------------------- 185s ++ dpkg --print-architecture 185s + arch=amd64 185s ++ py3versions -s 185s + pys=python3.13 185s + sourcetestroot=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests 185s + tomlfile=/tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 185s + echo amd64 i386 185s + grep amd64 185s ++ dpkg-vendor --query vendor 185s + '[' Debian = Ubuntu ']' 185s + marker='not slow' 185s + echo amd64 185s + grep -E 'mips|hppa' 185s === python3.13 === 185s + PYTEST_WARN_IGNORE= 185s + cd /tmp/autopkgtest.GEshUB/autopkgtest_tmp 185s + TEST_SUCCESS=true 185s + for py in $pys 185s + echo '=== python3.13 ===' 185s ++ python3.13 -c 'import pandas as pd; print(pd.__path__[0])' 186s + modpath=/usr/lib/python3/dist-packages/pandas 186s + for TEST_SUBSET in $modpath/tests/* 186s + echo /usr/lib/python3/dist-packages/pandas/tests/__init__.py 186s + grep -q -e __pycache__ 186s + PANDAS_CI=1 186s + LC_ALL=C.UTF-8 186s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/__init__.py 187s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 187s 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" 187s 187s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 187s ============================= test session starts ============================== 187s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 187s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 187s rootdir: /usr/lib/python3/dist-packages/pandas 187s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 187s 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 187s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 187s collected 0 items 187s 187s =============================== warnings summary =============================== 187s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 187s /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-qttf6es0' 187s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 187s 187s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 187s /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-0nsdlrqh' 187s session.config.cache.set(STEPWISE_CACHE_DIR, []) 187s 187s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 187s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 187s ============================= 2 warnings in 0.20s ============================== 187s rdjoqkol test state = true 187s + test 5 == 5 187s + echo 'rdjoqkol test state = true' 187s + for TEST_SUBSET in $modpath/tests/* 187s + echo /usr/lib/python3/dist-packages/pandas/tests/__pycache__ 187s + grep -q -e __pycache__ 187s rdjoqkol test state = true 187s + echo 'rdjoqkol test state = true' 187s + for TEST_SUBSET in $modpath/tests/* 187s + echo /usr/lib/python3/dist-packages/pandas/tests/api 187s + grep -q -e __pycache__ 187s + PANDAS_CI=1 187s + LC_ALL=C.UTF-8 187s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/api 188s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 188s 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" 188s 188s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 188s ============================= test session starts ============================== 188s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 188s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 188s rootdir: /usr/lib/python3/dist-packages/pandas 188s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 188s 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 188s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 188s collected 14 items 188s 189s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_api.py ............ 189s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_types.py .. 189s 189s =============================== warnings summary =============================== 189s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 189s /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-0u6rz2lx' 189s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 189s 189s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 189s /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-8ieb2k0w' 189s session.config.cache.set(STEPWISE_CACHE_DIR, []) 189s 189s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 189s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 189s ============================= slowest 30 durations ============================= 189s 189s (30 durations < 0.005s hidden. Use -vv to show these durations.) 189s ======================== 14 passed, 2 warnings in 0.19s ======================== 189s rdjoqkol test state = true 189s + echo 'rdjoqkol test state = true' 189s + for TEST_SUBSET in $modpath/tests/* 189s + echo /usr/lib/python3/dist-packages/pandas/tests/apply 189s + grep -q -e __pycache__ 189s + PANDAS_CI=1 189s + LC_ALL=C.UTF-8 189s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/apply 190s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 190s 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" 190s 190s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 190s ============================= test session starts ============================== 190s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 190s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 190s rootdir: /usr/lib/python3/dist-packages/pandas 190s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 190s 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 190s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 190s collected 1243 items 190s 191s ../../../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....... 192s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_apply_relabeling.py ..x.. 193s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_transform.py ...s.s.s................................................ss..ss..ss.....x........x........x........ 193s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_invalid_arg.py ....................................................................................................................................................................................................... 193s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_numba.py sssssssssssssssssss 194s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply.py ................................x.....x....x........................................................................................ 194s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply_relabeling.py .. 194s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_transform.py ............ 198s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_str.py ....................xxxxx...................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...........x...........x...........x...........x........ 198s 198s =============================== warnings summary =============================== 198s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 198s /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-8m8n1jmm' 198s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 198s 198s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 198s /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-ik_de0qo' 198s session.config.cache.set(STEPWISE_CACHE_DIR, []) 198s 198s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 198s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 198s ============================= slowest 30 durations ============================= 198s 0.08s call tests/apply/test_frame_apply.py::test_apply_differently_indexed 198s 0.05s call tests/apply/test_frame_apply.py::test_agg_transform[axis=1] 198s 0.04s call tests/apply/test_frame_apply.py::test_agg_transform[axis='columns'] 198s 0.03s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='columns'] 198s 0.03s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=1] 198s 0.03s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops3-names3] 198s 0.02s call tests/apply/test_series_apply.py::test_transform[compat] 198s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops1-names1] 198s 0.02s call tests/apply/test_series_apply.py::test_transform[False] 198s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops3-names3] 198s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops1-names1] 198s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops0-names0] 198s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops2-names2] 198s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops0-names0] 198s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops2-names2] 198s 0.01s call tests/apply/test_series_apply.py::test_with_nested_series[agg] 198s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis=0] 198s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis='index'] 198s 0.01s call tests/apply/test_series_apply.py::test_with_nested_series[apply] 198s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_namedtuple 198s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='index'] 198s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis='columns'-pct_change] 198s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=0] 198s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis=1-pct_change] 198s 0.01s call tests/apply/test_frame_apply.py::test_apply_mutating 198s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel_partial_functions 198s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel 198s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel_multi_columns_multi_methods 198s 0.01s call tests/apply/test_frame_apply.py::test_nuiscance_columns 198s 0.01s teardown tests/apply/test_str.py::test_transform_method_name[rank] 198s =========== 1153 passed, 73 skipped, 17 xfailed, 2 warnings in 8.07s =========== 198s rdjoqkol test state = true 198s + echo 'rdjoqkol test state = true' 198s + for TEST_SUBSET in $modpath/tests/* 198s + echo /usr/lib/python3/dist-packages/pandas/tests/arithmetic 198s + grep -q -e __pycache__ 198s + PANDAS_CI=1 198s + LC_ALL=C.UTF-8 198s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arithmetic 199s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 199s 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" 199s 199s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 202s ============================= test session starts ============================== 202s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 202s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 202s rootdir: /usr/lib/python3/dist-packages/pandas 202s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 202s 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 202s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 202s collected 19330 items 202s 202s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_array_ops.py .. 202s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_categorical.py .. 262s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_datetime64.py .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 264s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_interval.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 271s ../../../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............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 272s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_object.py .......s........................................................................................... 274s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_period.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 279s ../../../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......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 279s 279s =============================== warnings summary =============================== 279s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 279s /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-170hcss4' 279s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 279s 279s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 279s /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-1mzpy53r' 279s session.config.cache.set(STEPWISE_CACHE_DIR, []) 279s 279s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 279s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 279s ============================= slowest 30 durations ============================= 279s 0.28s call tests/arithmetic/test_datetime64.py::TestDatetimeIndexArithmetic::test_dti_addsub_offset_arraylike[zoneinfo.ZoneInfo(key='US/Pacific')-names3-series-add] 279s 0.18s call tests/arithmetic/test_datetime64.py::TestDatetime64Arithmetic::test_dt64arr_sub_timedeltalike_scalar[tzutc()-timedelta64_1-DataFrame] 279s 0.14s teardown tests/arithmetic/test_timedelta64.py::test_add_timestamp_to_timedelta 279s 0.07s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-us] 279s 0.07s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ns] 279s 0.07s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-True-cls_and_kwargs27] 279s 0.06s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ms] 279s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ns-5-True-cls_and_kwargs27] 279s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-s] 279s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-cls_and_kwargs27] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-False-cls_and_kwargs27] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-CBMonthBegin] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-True-cls_and_kwargs27] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-0-False-CBMonthBegin] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-CBMonthEnd] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[Series-US/Central-s-5-False-cls_and_kwargs27] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-False-cls_and_kwargs27] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-False-cls_and_kwargs27] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ns-5-True-cls_and_kwargs27] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ns-5-False-cls_and_kwargs27] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ns-5-False-cls_and_kwargs27] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-0-False-CBMonthEnd] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[Index-US/Central-s-5-True-cls_and_kwargs27] 279s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[array-US/Central-ms-5-False-cls_and_kwargs27] 279s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-0-False-CBMonthBegin] 279s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[Series-US/Central-us-5-True-cls_and_kwargs27] 279s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ms-5-True-cls_and_kwargs27] 279s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-0-False-CBMonthBegin] 279s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-us-5-True-cls_and_kwargs27] 279s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-us-5-False-cls_and_kwargs27] 279s ========== 19158 passed, 172 skipped, 2 warnings in 79.75s (0:01:19) =========== 281s rdjoqkol test state = true 281s + echo 'rdjoqkol test state = true' 281s + for TEST_SUBSET in $modpath/tests/* 281s + echo /usr/lib/python3/dist-packages/pandas/tests/arrays 281s + grep -q -e __pycache__ 281s + PANDAS_CI=1 281s + LC_ALL=C.UTF-8 281s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arrays 282s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 282s 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" 282s 282s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 286s ============================= test session starts ============================== 286s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 286s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 286s rootdir: /usr/lib/python3/dist-packages/pandas 286s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 286s 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 286s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 286s collected 19230 items / 2 skipped 286s 286s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_arithmetic.py ..................... 286s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_astype.py ... 286s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_comparison.py .................................... 287s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_construction.py ............................. 287s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_function.py ........... 287s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_indexing.py ... 287s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_logical.py ................................................................................... 287s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_ops.py .. 287s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_reduction.py .............................. 287s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_repr.py . 287s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_algos.py .............. 287s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_analytics.py ........x..x................................................ 287s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_api.py ................................................................. 287s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_astype.py ...................... 287s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_constructors.py ....................................................................................................................... 288s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_dtypes.py .................................. 288s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_indexing.py ............................................................................................................................................... 288s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_map.py ............................. 288s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_missing.py .......................... 288s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_operators.py ...................................... 288s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_replace.py ...................... 288s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_repr.py ....................... 288s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_sorting.py .... 288s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_subclass.py ... 288s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_take.py ................ 288s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_warnings.py s 288s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_constructors.py ......................ssssssssssssss 288s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_cumulative.py ... 289s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_reductions.py ................................................................................................................................................................................................................. 289s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_arithmetic.py .............................................................. 289s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_astype.py ......... 289s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_comparison.py .................................................................................................................. 289s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_concat.py ... 289s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_construction.py ............................... 289s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_contains.py . 289s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_function.py .................................................... 289s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_repr.py ........ 290s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_to_numpy.py .............................. 290s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_arithmetic.py ................................................................................................................................................................................................................................................................................................................................................... 291s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_comparison.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 291s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_concat.py .................. 291s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_construction.py ............................................... 292s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_dtypes.py ......................................................................................................................... 292s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_function.py ............................................................................................................................. 292s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_indexing.py .. 292s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_reduction.py ............................................... 292s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_repr.py .......................... 292s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_astype.py .. 292s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_formats.py . 292s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval.py .............................................................................. 292s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval_pyarrow.py ssssssss 293s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_overlaps.py .................................................................................................................... 295s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_arithmetic.py ..............................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss............................................................................................................................................................................................................................................................................................................................................................... 295s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_function.py ..................... 295s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_indexing.py ........................................................................................................... 295s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_indexing.py ....................................... 295s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_numpy.py ....................................................................................... 295s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_astype.py .......... 295s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_constructors.py ..................... 295s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_reductions.py ... 296s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_accessor.py ............................................. 298s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_arithmetics.py ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 299s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_array.py ........................................................................... 299s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_astype.py ........................ 299s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_combine_concat.py .......... 299s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_constructors.py ................................. 299s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_dtype.py ........................................................ 299s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_indexing.py ................................................................................ 299s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_libsparse.py ..................................................................................... 299s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_reductions.py ....................................................................... 299s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_unary.py ......... 301s ../../../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 301s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/string_/test_string_arrow.py s.ss.ssssssssss.ssssssssssssssssssssssssssssssssss 301s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_array.py ....................................................................................... 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimelike.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssss....................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssss.......................................................................................................................................................................................................................................................................................................................................... 329s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimes.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 329s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_ndarray_backed.py ..... 329s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_period.py ................... 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_timedeltas.py ...................................................................................................................................................... 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_constructors.py ........ 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_cumulative.py ..... 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_reductions.py .......................... 330s 330s =============================== warnings summary =============================== 330s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 330s /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-a4ck4u0c' 330s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 330s 330s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 330s /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-b90th4jm' 330s session.config.cache.set(STEPWISE_CACHE_DIR, []) 330s 330s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 330s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 330s ============================= slowest 30 durations ============================= 330s 0.38s call tests/arrays/test_timedeltas.py::TestNonNano::test_mul_listlike_object[s] 330s 0.27s call tests/arrays/test_datetimelike.py::TestDatetimeArray::test_setitem_object_dtype['UTC+01:15'-QE-Index] 330s 0.21s setup tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_bool_array_logical[integer-True] 330s 0.15s teardown tests/arrays/timedeltas/test_reductions.py::TestReductions::test_mean_2d 330s 0.12s call tests/arrays/sparse/test_accessor.py::TestSeriesAccessor::test_from_coo 330s 0.05s call tests/arrays/categorical/test_dtypes.py::TestCategoricalDtypes::test_codes_dtypes 330s 0.03s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[block] 330s 0.03s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[integer] 330s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[block] 330s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[integer] 330s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[block] 330s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[integer] 330s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[block] 330s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[integer] 330s 0.01s call tests/arrays/integer/test_arithmetic.py::test_values_multiplying_large_series_by_NA 330s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-labels1-coo] 330s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-labels1-csr] 330s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-labels1-csc] 330s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[QE] 330s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[int64-None-csc] 330s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-None-csc] 330s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-None-csr] 330s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[int64-None-csr] 330s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-None-coo] 330s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[int64-None-coo] 330s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[YE] 330s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[int64-labels1-coo] 330s 0.01s call tests/arrays/test_period.py::test_repr_large 330s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[int64-labels1-csr] 330s 0.01s call tests/arrays/categorical/test_api.py::TestCategoricalAPIWithFactor::test_describe 330s ========= 18203 passed, 1021 skipped, 8 xfailed, 2 warnings in 48.44s ========== 332s rdjoqkol test state = true 332s + echo 'rdjoqkol test state = true' 332s + for TEST_SUBSET in $modpath/tests/* 332s + echo /usr/lib/python3/dist-packages/pandas/tests/base 332s + grep -q -e __pycache__ 332s + PANDAS_CI=1 332s + LC_ALL=C.UTF-8 332s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/base 333s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 333s 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" 333s 333s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 333s ============================= test session starts ============================== 333s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 333s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 333s rootdir: /usr/lib/python3/dist-packages/pandas 333s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 333s 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 333s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 333s collected 1775 items 333s 333s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_constructors.py ....................... 334s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_conversion.py ................................................................................................................................................................................................................................................................................................................................... 334s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_fillna.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss 335s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_misc.py .......................................................................................................................................................................................................................................xx...xxx....................................................................s...... 335s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_transpose.py .............................................................................................................................................................................................................................. 336s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_unique.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss..................................................................................ssssssssssssssssss....ssss..........ssssssss......ss......................................................................ssssssssssss.... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_value_counts.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss......................... 337s 337s =============================== warnings summary =============================== 337s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 337s /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-5r61fumi' 337s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 337s 337s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 337s /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-jppw2y3g' 337s session.config.cache.set(STEPWISE_CACHE_DIR, []) 337s 337s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 337s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 337s ============================= slowest 30 durations ============================= 337s 0.04s setup tests/base/test_misc.py::test_memory_usage[datetime] 337s 0.03s call tests/base/test_value_counts.py::test_value_counts_null[interval-nan] 337s 0.03s call tests/base/test_value_counts.py::test_value_counts_null[interval-None] 337s 0.02s call tests/base/test_value_counts.py::test_value_counts[interval] 337s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[period-nan] 337s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[period-None] 337s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-None] 337s 0.01s call tests/base/test_value_counts.py::test_value_counts_bins[index] 337s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-nan] 337s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-nan] 337s 0.01s call tests/base/test_value_counts.py::test_value_counts_bins[series] 337s 0.01s call tests/base/test_value_counts.py::test_value_counts[datetime-tz] 337s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-tz-nan] 337s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-nan] 337s 0.01s call tests/base/test_unique.py::test_unique_null[period-nan] 337s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-None] 337s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-None] 337s 0.01s teardown tests/base/test_value_counts.py::test_value_counts_object_inference_deprecated 337s 0.01s call tests/base/test_value_counts.py::test_value_counts[period] 337s 0.01s call tests/base/test_value_counts.py::test_value_counts[timedelta] 337s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-nan] 337s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-tz-None] 337s 0.01s call tests/base/test_unique.py::test_unique_null[timedelta-None] 337s 0.01s call tests/base/test_unique.py::test_unique[datetime-tz] 337s 0.01s call tests/base/test_unique.py::test_unique_null[timedelta-nan] 337s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-None] 337s 0.01s call tests/base/test_unique.py::test_unique[timedelta] 337s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[string-python-None] 337s 0.01s call tests/base/test_unique.py::test_unique_null[period-None] 337s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[string-python-nan] 337s =========== 1581 passed, 189 skipped, 5 xfailed, 2 warnings in 4.08s =========== 337s + echo 'rdjoqkol test state = true' 337s rdjoqkol test state = true 337s + for TEST_SUBSET in $modpath/tests/* 337s + echo /usr/lib/python3/dist-packages/pandas/tests/computation 337s + grep -q -e __pycache__ 337s + PANDAS_CI=1 337s + LC_ALL=C.UTF-8 337s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/computation 338s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 338s 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" 338s 338s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 340s ============================= test session starts ============================== 340s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 340s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 340s rootdir: /usr/lib/python3/dist-packages/pandas 340s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 340s 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 340s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 340s collected 11159 items 340s 340s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_compat.py ..... 406s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_eval.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xx..............................xx..............................xx..............................xx.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxxxxxxxx..................................................xxxxxxxxxx......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................X.........X....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................xx..xx..... 406s 406s =============================== warnings summary =============================== 406s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 406s /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-vkrbct2k' 406s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 406s 406s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 406s /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-rk_qbwm1' 406s session.config.cache.set(STEPWISE_CACHE_DIR, []) 406s 406s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 406s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 406s ============================= slowest 30 durations ============================= 406s 0.21s teardown tests/computation/test_eval.py::TestEval::test_floor_division[DataFrame-SeriesNaN-numexpr-python] 406s 0.11s call tests/computation/test_eval.py::TestEval::test_complex_cmp_ops[SeriesNaN-Series-numexpr-python-and-lt-ge] 406s 0.07s teardown tests/computation/test_eval.py::TestValidate::test_validate_bool_args[5.0] 406s 0.06s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-python] 406s 0.05s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-pandas] 406s 0.04s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-python] 406s 0.04s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-pandas] 406s 0.03s call tests/computation/test_eval.py::TestOperations::test_lhs_expression_subscript 406s 0.03s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[numexpr-python] 406s 0.02s call tests/computation/test_eval.py::TestOperations::test_nested_period_index_subscript_expression 406s 0.02s call tests/computation/test_eval.py::TestOperations::test_attr_expression 406s 0.02s setup tests/computation/test_eval.py::TestEval::test_complex_cmp_ops[DataFrame-DataFrame-numexpr-python-and-lt-lt] 406s 0.02s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-python-|] 406s 0.02s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[python-python] 406s 0.02s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[numexpr-pandas] 406s 0.02s call tests/computation/test_eval.py::TestOperations::test_multi_line_expression 406s 0.02s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[numexpr-python] 406s 0.02s call tests/computation/test_eval.py::TestEval::test_binary_arith_ops[DataFrameNaN-SeriesNaN-numexpr-python--] 406s 0.02s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-pandas-|] 406s 0.02s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-pandas-&] 406s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-python-|] 406s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-python-&] 406s 0.01s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[numexpr-pandas] 406s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-dt-i-s1] 406s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-dt-i-i] 406s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-i-i-dt] 406s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-pandas-|] 406s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-pandas-&] 406s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-dt-s-i] 406s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-python-&] 406s ===== 11124 passed, 33 xfailed, 2 xpassed, 2 warnings in 67.93s (0:01:07) ====== 407s rdjoqkol test state = true 407s + echo 'rdjoqkol test state = true' 407s + for TEST_SUBSET in $modpath/tests/* 407s + echo /usr/lib/python3/dist-packages/pandas/tests/config 407s + grep -q -e __pycache__ 407s + PANDAS_CI=1 407s + LC_ALL=C.UTF-8 407s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/config 408s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 408s 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" 408s 408s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 409s ============================= test session starts ============================== 409s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 409s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 409s rootdir: /usr/lib/python3/dist-packages/pandas 409s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 409s 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 409s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 409s collected 50 items 409s 409s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_config.py ..................... 409s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_localization.py ............................. 409s 409s =============================== warnings summary =============================== 409s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 409s /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-9yil17z1' 409s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 409s 409s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 409s /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-n6dm4sq1' 409s session.config.cache.set(STEPWISE_CACHE_DIR, []) 409s 409s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 409s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 409s ============================= slowest 30 durations ============================= 409s 0.02s call tests/config/test_localization.py::test_get_locales_prefix 409s 409s (29 durations < 0.005s hidden. Use -vv to show these durations.) 409s ======================== 50 passed, 2 warnings in 0.80s ======================== 410s + echo 'rdjoqkol test state = true' 410s + for TEST_SUBSET in $modpath/tests/* 410s + echo /usr/lib/python3/dist-packages/pandas/tests/construction 410s + grep -q -e __pycache__ 410s + PANDAS_CI=1 410s + LC_ALL=C.UTF-8 410s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/construction 410s rdjoqkol test state = true 410s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 410s 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" 410s 410s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 411s ============================= test session starts ============================== 411s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 411s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 411s rootdir: /usr/lib/python3/dist-packages/pandas 411s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 411s 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 411s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 411s collected 1 item 411s 411s ../../../usr/lib/python3/dist-packages/pandas/tests/construction/test_extract_array.py . 411s 411s =============================== warnings summary =============================== 411s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 411s /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-2p__dumg' 411s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 411s 411s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 411s /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-9l7rgsjs' 411s session.config.cache.set(STEPWISE_CACHE_DIR, []) 411s 411s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 411s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 411s ============================= slowest 30 durations ============================= 411s 411s (3 durations < 0.005s hidden. Use -vv to show these durations.) 411s ======================== 1 passed, 2 warnings in 0.13s ========================= 411s + echo 'rdjoqkol test state = true' 411s + for TEST_SUBSET in $modpath/tests/* 411s rdjoqkol test state = true 411s + echo /usr/lib/python3/dist-packages/pandas/tests/copy_view 411s + grep -q -e __pycache__ 411s + PANDAS_CI=1 411s + LC_ALL=C.UTF-8 411s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/copy_view 412s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 412s 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" 412s 412s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 414s ============================= test session starts ============================== 414s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 414s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 414s rootdir: /usr/lib/python3/dist-packages/pandas 414s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 414s 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 414s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 414s collected 793 items 414s 414s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_datetimeindex.py ...... 414s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_index.py ..................... 414s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_periodindex.py .. 414s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_timedeltaindex.py .. 414s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_array.py ............. 414s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_astype.py .....ss...s..........s.. 414s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_chained_assignment_deprecation.py ............... 414s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_clip.py ...... 414s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_constructors.py ............................................................................ 414s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_core_functionalities.py ....... 414s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_functions.py .................... 415s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_indexing.py ....................................................................................s.....s........................................................................................................................................ 415s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_internals.py ..................... 415s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_interp_fillna.py ...................................................... 416s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_methods.py ........................................................................................................................................................................................................................................................ 416s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_replace.py ........................................ 416s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_setitem.py ......... 416s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_util.py .. 416s 416s =============================== warnings summary =============================== 416s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 416s /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-fmdl9dih' 416s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 416s 416s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 416s /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-6gttsmsj' 416s session.config.cache.set(STEPWISE_CACHE_DIR, []) 416s 416s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 416s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 416s ============================= slowest 30 durations ============================= 416s 0.02s call tests/copy_view/test_internals.py::test_exponential_backoff 416s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_column_indexer[nullable-array] 416s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_column_indexer[nullable-slice] 416s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_column_indexer[nullable-mask] 416s 0.01s call tests/copy_view/test_indexing.py::test_midx_read_only_bool_indexer 416s 0.01s call tests/copy_view/test_indexing.py::test_subset_set_with_mask[nullable] 416s 0.01s call tests/copy_view/test_indexing.py::test_subset_chained_getitem[nullable-single-block-row-getitem-slice] 416s 0.01s teardown tests/copy_view/test_util.py::test_get_array_masked 416s 0.01s call tests/copy_view/test_indexing.py::test_subset_loc_rows_columns[nullable-array-slice-single-block] 416s 416s (21 durations < 0.005s hidden. Use -vv to show these durations.) 416s ================== 787 passed, 6 skipped, 2 warnings in 3.88s ================== 416s + echo 'rdjoqkol test state = true' 416s rdjoqkol test state = true 416s + for TEST_SUBSET in $modpath/tests/* 416s + echo /usr/lib/python3/dist-packages/pandas/tests/dtypes 416s + grep -q -e __pycache__ 416s + PANDAS_CI=1 416s + LC_ALL=C.UTF-8 416s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/dtypes 417s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 417s 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" 417s 417s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 419s ============================= test session starts ============================== 419s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 419s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 419s rootdir: /usr/lib/python3/dist-packages/pandas 419s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 419s 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 419s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 419s collected 5628 items 419s 419s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_can_hold_element.py ........... 419s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_from_scalar.py .... 419s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_ndarray.py ....... 419s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_object_arr.py ....................................... 419s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_dict_compat.py . 419s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_downcast.py ................................... 419s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_find_common_type.py .......................................................................................... 419s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_datetimelike.py ... 420s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_dtype.py .................................................................... 420s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_maybe_box_native.py ................ 424s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_promote.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 425s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_common.py .............................................................................................................................................................................s...................................................................................................................................................................................................................................................................... 425s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_concat.py .... 425s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_dtypes.py ........................................................................................................................................................................................................................................................................................... 426s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_generic.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 427s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_inference.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss....................................................... 427s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_missing.py ..........................................................................................................xxxx............................................................................................................................................................................................................. 427s 427s =============================== warnings summary =============================== 427s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 427s /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-rqalu7vl' 427s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 427s 427s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 427s /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-8k0w08f0' 427s session.config.cache.set(STEPWISE_CACHE_DIR, []) 427s 427s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 427s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 427s ============================= slowest 30 durations ============================= 427s 0.12s call tests/dtypes/test_common.py::test_is_sparse[True] 427s 0.09s call tests/dtypes/test_inference.py::TestInference::test_maybe_convert_objects_mixed_datetimes 427s 0.03s teardown tests/dtypes/test_missing.py::TestIsValidNAForDtype::test_is_valid_na_for_dtype_categorical 427s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[int32] 427s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[int64] 427s 0.01s call tests/dtypes/test_generic.py::TestABCClasses::test_abc_pairs_instance_check[ABCRangeIndex-_2-ABCTimedeltaIndex-inst3] 427s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[int8] 427s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[uint8] 427s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[uint64] 427s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[uint16] 427s 427s (20 durations < 0.005s hidden. Use -vv to show these durations.) 427s =========== 5615 passed, 9 skipped, 4 xfailed, 2 warnings in 10.59s ============ 428s + echo 'rdjoqkol test state = true' 428s + for TEST_SUBSET in $modpath/tests/* 428s + grep -q -e __pycache__ 428s + echo /usr/lib/python3/dist-packages/pandas/tests/extension 428s + PANDAS_CI=1 428s + LC_ALL=C.UTF-8 428s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/extension 428s rdjoqkol test state = true 429s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 429s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 429s 429s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 435s ============================= test session starts ============================== 435s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 435s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 435s rootdir: /usr/lib/python3/dist-packages/pandas 435s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 435s 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 435s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 435s collected 16808 items / 1 skipped 435s 435s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/array_with_attr/test_array_with_attr.py . 440s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/decimal/test_decimal.py ssssssssssssssssssssssssssssssssssss....................................x.................................................................................................................................................................................................................................................................................................................................xx............................................................s............................xxxxxxxxss..............xxssxxss................................................xxx..................... 460s ../../../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. 460s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/list/test_list.py . 462s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_categorical.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss...................................s.........................................................................................................................ss.................................................................................................xx...........................................................s............x..sxx................x.............xxxxxssssssssssssssssssssssssssssssssssss.. 462s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_common.py ............ 465s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_datetime.py ........................ssss............................................x..............................................................................................ssssssssssssssssssssssss.................................................................s......................................................................................................................................................................................xx..............................................xx...........................................................s............................................ssss......... 465s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_extension.py .............. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_interval.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss.................................................................s...............................................................................................................................ss......................................................xx..............................................xx............................................................s............x. 491s ../../../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 499s ../../../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.. 503s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_period.py ..........................................ssss........ssss.....................................................................................x...x..................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssss..................................................................................................................................ss........................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxx.......................................................................................................................s.s............................................................................ssss........ssss................ 518s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_sparse.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss..ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss....................................ssss................................................................................................................................................................................................................................................................................................................................................................................................xxxx........................ssss..............................................................xxxx..........................................................................................................................................xxxxxxxxxxxxxx...x.x.x.xxxxxxxxxxxxxxxss........xxxxxxxxssxxssss.x.x.x.xxxxxxxxxssxxss..........s.s.s.s.s.s...s......xxx......xx........ss..ssssss................xsxsssssssssssssss..............ssssssssssssss..............xxxx....xx.x............................x..x.x......xx.xxx......xxxxxx. 525s ../../../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 525s 525s =============================== warnings summary =============================== 525s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 525s /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-8821wcoq' 525s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 525s 525s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 525s /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-9ymbd4je' 525s session.config.cache.set(STEPWISE_CACHE_DIR, []) 525s 525s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 525s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 525s ============================= slowest 30 durations ============================= 525s 0.19s call tests/extension/test_masked.py::TestMaskedArrays::test_setitem_loc_scalar_mixed[Int16Dtype] 525s 0.14s call tests/extension/json/test_json.py::TestJSONArray::test_unary_ufunc_dunder_equivalence[negative] 525s 0.09s teardown tests/extension/test_string.py::test_searchsorted_with_na_raises[False-False-pyarrow_numpy] 525s 0.07s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index2] 525s 0.07s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int8Dtype-series-index2] 525s 0.07s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index3] 525s 0.07s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_unstack[series-index2] 525s 0.06s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index2] 525s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float32Dtype-series-index2] 525s 0.06s call tests/extension/test_numpy.py::TestNumpyExtensionArray::test_unstack[float-series-index3] 525s 0.06s call tests/extension/test_string.py::TestStringArray::test_unstack[False-python-frame-index2] 525s 0.06s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_unstack[series-index3] 525s 0.06s call tests/extension/test_string.py::TestStringArray::test_unstack[True-python-series-index2] 525s 0.06s call tests/extension/test_numpy.py::TestNumpyExtensionArray::test_unstack[float-series-index2] 525s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float64Dtype-frame-index2] 525s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int8Dtype-series-index3] 525s 0.06s call tests/extension/test_string.py::TestStringArray::test_unstack[False-python-series-index2] 525s 0.06s call tests/extension/test_string.py::TestStringArray::test_unstack[False-python-series-index3] 525s 0.06s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index3] 525s 0.06s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[frame-index2] 525s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float64Dtype-series-index3] 525s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int16Dtype-series-index3] 525s 0.06s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_unstack[frame-index2] 525s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int8Dtype-frame-index2] 525s 0.06s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[series-index2] 525s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int16Dtype-series-index2] 525s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int32Dtype-series-index2] 525s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[BooleanDtype-series-index2] 525s 0.05s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[series-index3] 525s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float64Dtype-series-index2] 525s === 12106 passed, 4371 skipped, 332 xfailed, 2 warnings in 95.82s (0:01:35) ==== 527s rdjoqkol test state = true 527s + echo 'rdjoqkol test state = true' 527s + for TEST_SUBSET in $modpath/tests/* 527s + echo /usr/lib/python3/dist-packages/pandas/tests/frame 527s + grep -q -e __pycache__ 527s + PANDAS_CI=1 527s + LC_ALL=C.UTF-8 527s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/frame 528s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 528s 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" 528s 528s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 535s ============================= test session starts ============================== 535s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 535s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 535s rootdir: /usr/lib/python3/dist-packages/pandas 535s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 535s 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 535s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 535s collected 11172 items / 433 deselected / 1 skipped / 10739 selected 535s 535s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_dict.py .............. 535s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_records.py ........................... 536s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_coercion.py .......x.x. 536s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_delitem.py .... 536s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get.py .... 536s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get_value.py .. 536s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_getitem.py ........................................ 538s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_indexing.py ...................................................................................................................................................................................................................................sss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 538s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_insert.py ....... 538s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_mask.py ........... 538s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_set_value.py ... 539s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_setitem.py ........................................................................................................s..........................................................................................xxx...........................x..x..x..x........ 539s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_take.py .... 543s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_where.py ............................................................................................................................................. 543s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_xs.py .............................. 543s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_add_prefix_suffix.py ... 545s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_align.py ........................................................................................................................................................................................................................................................................................................................................................................................................................ 545s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asfreq.py ........................................ 545s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asof.py ........... 545s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_assign.py ..... 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_astype.py .......................................................................................................................s....s........................................................................................................ss.....ssssssssss 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_at_time.py ...................... 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_between_time.py .............................. 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_clip.py ..................... 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine.py ..... 547s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine_first.py ..................................s............................... 547s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_compare.py ......................... 547s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_convert_dtypes.py ..ssss..ssss.sss.. 547s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_copy.py ..... 547s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_count.py .. 548s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_cov_corr.py .............................................................s............ 548s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_describe.py ...............................................s 548s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_diff.py .............................................. 548s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dot.py ................sss 549s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop.py ......................................................................... 549s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop_duplicates.py ..................................... 549s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_droplevel.py .. 549s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dropna.py ................... 549s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dtypes.py ........ 549s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_duplicated.py .......xxx........... 549s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_equals.py ... 549s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_explode.py ..................... 549s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_fillna.py ................................................................. 549s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_filter.py ........... 549s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_and_last.py ............. 549s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_valid_index.py ............... 549s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_get_numeric_data.py .... 551s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_head_tail.py .................................................................. 551s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_infer_objects.py . 552s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_info.py ..........................x......s...... 553s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_interpolate.py ...................................................................ssssssssss 553s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_is_homogeneous_dtype.py ....... 553s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isetitem.py ... 553s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isin.py ................. 553s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_iterrows.py . 553s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_join.py ...........s................... 553s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_map.py ......................... 553s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_matmul.py .. 554s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_nlargest.py .........................................................................................................................................................................................................................................................x.....x.....x.....x.......x..... 554s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pct_change.py ............................. 554s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pipe.py ...... 554s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pop.py ... 558s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_quantile.py ........................................................................xx..........xx..........xx..........xx.................. 561s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rank.py .........................................................................................................................ss 562s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex.py ................................................................................................................................................. 562s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex_like.py ..... 562s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename.py ......................... 562s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename_axis.py ......... 562s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reorder_levels.py ... 562s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_replace.py ...................ss.................ssss....ssss................................................................................................................................................................. 563s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reset_index.py ................................................................................................................................ 563s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_round.py ......... 563s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sample.py .......................................................... 563s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_select_dtypes.py ..................................s...... 563s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_axis.py .............. 566s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_index.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 570s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_shift.py ...................................................................................x.x.x.x.x.xxxx........ 570s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_size.py ..... 571s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_index.py ................................................................. 571s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_values.py ...................................................X...............................xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX..... 571s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swapaxes.py .... 571s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swaplevel.py . 574s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_csv.py ............................................................................. 574s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict.py ...................................................................................................... 574s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict_of_blocks.py ... 574s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_numpy.py .... 575s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_period.py ...................................................................... 575s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_records.py ................................... 575s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_timestamp.py ...................................................................... 575s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_transpose.py ................... 575s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_truncate.py ........................................................................................ 575s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_convert.py ........... 575s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_localize.py ......... 575s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_update.py .............. 575s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_value_counts.py ................................. 575s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_values.py ............... 575s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_alter_axes.py .. 576s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_api.py ......................ss.......... 580s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..........x................................................................................................................................ 580s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_block_internals.py ................... 583s ../../../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................................ 583s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_cumulative.py ....... 583s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_iteration.py .................... 583s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_logical_ops.py ................. 583s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_nonunique_indexes.py ................ 583s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_npfuncs.py .... 586s ../../../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. 591s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_reductions.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s....................................................................................................x.............x............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 591s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_repr.py ..........................................ssss................ 600s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_stack_unstack.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 600s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_subclass.py .................................................... 602s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 602s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_unary.py .................. 602s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_validate.py ............................ 602s 602s =============================== warnings summary =============================== 602s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 602s /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-58f390jj' 602s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 602s 602s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 602s /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-s28s5j6n' 602s session.config.cache.set(STEPWISE_CACHE_DIR, []) 602s 602s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 602s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 602s ============================= slowest 30 durations ============================= 602s 2.64s call tests/frame/indexing/test_where.py::test_where_inplace_casting 602s 2.35s call tests/frame/methods/test_rank.py::TestRank::test_pct_max_many_rows 602s 0.85s call tests/frame/test_api.py::TestDataFrameMisc::test_inspect_getmembers 602s 0.53s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorr::test_corr_scipy_method[kendall] 602s 0.53s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[10000] 602s 0.50s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_with_dst_transitions_with_pickle 602s 0.45s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[50000] 602s 0.39s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[100000] 602s 0.33s 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] 602s 0.27s call tests/frame/methods/test_info.py::test_info_verbose_check_header_separator_body 602s 0.20s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorrWith::test_corrwith[Float64] 602s 0.20s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_dups_cols 602s 0.18s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[False] 602s 0.16s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[False] 602s 0.16s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[index] 602s 0.15s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[0] 602s 0.15s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[True] 602s 0.12s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_bytes_61_lines 602s 0.12s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_to_string 602s 0.12s call tests/frame/test_iteration.py::TestIteration::test_itertuples_py2_3_field_limit_namedtuple[True-1024] 602s 0.11s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[columns-1] 602s 0.11s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[False] 602s 0.11s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[True] 602s 0.11s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[index-0] 602s 0.10s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[True] 602s 0.09s call tests/frame/test_stack_unstack.py::TestDataFrameReshape::test_stack_int_level_names[False] 602s 0.08s call tests/frame/methods/test_head_tail.py::test_head_tail_generic[int8-DataFrame] 602s 0.08s call tests/frame/test_block_internals.py::TestDataFrameBlockInternals::test_strange_column_corruption_issue 602s 0.07s call tests/frame/methods/test_head_tail.py::test_head_tail_generic[interval-DataFrame] 602s 0.07s call tests/frame/methods/test_head_tail.py::test_head_tail_generic[nullable_uint-DataFrame] 602s = 10438 passed, 206 skipped, 433 deselected, 64 xfailed, 32 xpassed, 2 warnings in 73.80s (0:01:13) = 604s rdjoqkol test state = true 604s + echo 'rdjoqkol test state = true' 604s + for TEST_SUBSET in $modpath/tests/* 604s + echo /usr/lib/python3/dist-packages/pandas/tests/generic 604s + grep -q -e __pycache__ 604s + PANDAS_CI=1 604s + LC_ALL=C.UTF-8 604s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/generic 604s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 604s 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" 604s 604s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 605s ============================= test session starts ============================== 605s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 605s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 605s rootdir: /usr/lib/python3/dist-packages/pandas 605s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 605s 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 605s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 605s collected 1249 items 605s 606s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_duplicate_labels.py ..........xx...........x.......xx.xxx................x................ 611s ../../../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. 611s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_frame.py ............... 611s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_generic.py ................................................................................. 611s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_label_or_level_utils.py ....................................................................... 611s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_series.py ................... 612s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py expected 612s bar a b c d e f g h 612s foo 612s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) object 32B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='datetime64[ns]', name='foo', freq='D') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) datetime64[ns] 32B 2020-01-01 2020-01-02 ... 2020-01-04 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='datetime64[ns]', name='foo', freq='D') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c ... f g h 612s foo ... 612s 2020-01-01 00:00:00-08:00 a 1 3 ... a 2013-01-01 2013-01-01 00:00:00-05:00 612s 2020-01-02 00:00:00-08:00 b 2 4 ... b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2020-01-03 00:00:00-08:00 c 3 5 ... c 2013-01-03 2013-01-03 00:00:00-05:00 612s 2020-01-04 00:00:00-08:00 d 4 6 ... d 2013-01-04 2013-01-04 00:00:00-05:00 612s 612s [4 rows x 8 columns] 612s DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 612s '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 612s dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) object 32B 1577865600000000000 ... 1578124800000000000 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c ... f g h 612s foo ... 612s 2020-01-01 00:00:00-08:00 a 1 3 ... NaN 2013-01-01 2013-01-01 00:00:00-05:00 612s 2020-01-02 00:00:00-08:00 b 2 4 ... NaN 2013-01-02 2013-01-02 00:00:00-05:00 612s 2020-01-03 00:00:00-08:00 c 3 5 ... NaN 2013-01-03 2013-01-03 00:00:00-05:00 612s 2020-01-04 00:00:00-08:00 d 4 6 ... NaN 2013-01-04 2013-01-04 00:00:00-05:00 612s 612s [4 rows x 8 columns] 612s Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 612s 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 612s dtype='object', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s xexpected 612s bar a b c d e f g h 612s foo 612s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s PeriodIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='period[D]', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) object 32B 2020-01-01 2020-01-02 2020-01-03 2020-01-04 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s PeriodIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='period[D]', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 1 days a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 2 days b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 3 days c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 4 days d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', name='foo', freq='D') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) timedelta64[ns] 32B 1 days 2 days 3 days 4 days 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 1 days a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 2 days b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 3 days c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 4 days d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', name='foo', freq='D') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s RangeIndex(start=0, stop=4, step=1, name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) int64 32B 0 1 2 3 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s RangeIndex(start=0, stop=4, step=1, name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='int8', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 208B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) int8 4B 0 1 2 3 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='int8', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='int16', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 212B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) int16 8B 0 1 2 3 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='int16', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='int32', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 220B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) int32 16B 0 1 2 3 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='int32', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='int64', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) int64 32B 0 1 2 3 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='int64', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='uint8', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 208B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) uint8 4B 0 1 2 3 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='uint8', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='uint16', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 212B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) uint16 8B 0 1 2 3 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='uint16', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='uint32', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 220B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) uint32 16B 0 1 2 3 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='uint32', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='uint64', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) uint64 32B 0 1 2 3 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='uint64', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0.0, 1.0, 2.0, 3.0], dtype='float32', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 220B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) float32 16B 0.0 1.0 2.0 3.0 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0.0, 1.0, 2.0, 3.0], dtype='float32', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0.0, 1.0, 2.0, 3.0], dtype='float64', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) float64 32B 0.0 1.0 2.0 3.0 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0.0, 1.0, 2.0, 3.0], dtype='float64', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([True, False, True, False], dtype='object', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) object 32B True False True False 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s True a 1 3 4.0 True c 2013-01-01 2013-01-01 00:00:00-05:00 612s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s False b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 612s True c 3 5 6.0 True a 2013-01-03 2013-01-03 00:00:00-05:00 612s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s False d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 612s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([True, True, False, False, True, True, False, False], dtype='object', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s xexpected 612s bar a b c d e f g h 612s foo 612s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([True, False, True, False], dtype='bool', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 208B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) bool 4B True False True False 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s True a 1 3 4.0 True c 2013-01-01 2013-01-01 00:00:00-05:00 612s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s False b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 612s True c 3 5 6.0 True a 2013-01-03 2013-01-03 00:00:00-05:00 612s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s False d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 612s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([True, True, False, False, True, True, False, False], dtype='bool', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s xexpected 612s bar a b c d e f g h 612s foo 612s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex64', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) complex64 32B 0j (1+1j) (2+2j) (3+3j) 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex64', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex128', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 268B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) complex128 64B 0j (1+1j) (2+2j) (3+3j) 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex128', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xexpected 612s bar a b c d e f g h 612s foo 612s a a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s b b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s c c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) object 32B 'a' 'b' 'c' 'd' 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s a a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s b b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s c c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s xexpected 612s bar a b c d e f g h 612s foo 612s (0.0, 1.0] a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s (1.0, 2.0] b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s (2.0, 3.0] c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s (3.0, 4.0] d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s IntervalIndex([(0.0, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]], dtype='interval[float64, right]', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) object 32B (0.0, 1.0] (1.0, 2.0] (2.0, 3.0] (3.0, 4.0] 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s (0.0, 1.0] a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s (1.0, 2.0] b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s (2.0, 3.0] c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s (3.0, 4.0] d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s IntervalIndex([(0.0, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]], dtype='interval[float64, right]', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s Xsexpected 612s bar a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 1 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 0, 1, 1], dtype='int64', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) int64 32B 0 0 1 1 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 0 a 1 3 4.0 True b 2013-01-01 2013-01-01 00:00:00-05:00 612s 0 b 2 4 5.0 False a 2013-01-02 2013-01-02 00:00:00-05:00 612s 0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 1 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 1 c 3 5 6.0 True d 2013-01-03 2013-01-03 00:00:00-05:00 612s 1 d 4 6 7.0 False c 2013-01-04 2013-01-04 00:00:00-05:00 612s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 0, 0, 0, 1, 1, 1, 1], dtype='int64', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s xexpected 612s bar a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='Int64', name='foo') 612s bar 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 612s actual 612s Size: 236B 612s Dimensions: (foo: 4) 612s Coordinates: 612s * foo (foo) object 32B 0 1 2 3 612s Data variables: 612s a (foo) object 32B 'a' 'b' 'c' 'd' 612s b (foo) int64 32B 1 2 3 4 612s c (foo) uint8 4B 3 4 5 6 612s d (foo) float64 32B 4.0 5.0 6.0 7.0 612s e (foo) bool 4B True False True False 612s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 612s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 612s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 612s a b c d e f g h 612s foo 612s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 612s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 612s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 612s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 612s Index([0, 1, 2, 3], dtype='object', name='foo') 612s a object 612s b int64 612s c uint8 612s d float64 612s e bool 612s f category 612s g datetime64[ns] 612s h datetime64[ns, US/Eastern] 612s dtype: object 613s xexpected 613s bar a b c d e f g h 613s foo 613s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 613s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 613s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 613s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 613s Index([0, 1, 2, 3], dtype='UInt16', name='foo') 613s bar 613s a object 613s b int64 613s c uint8 613s d float64 613s e bool 613s f category 613s g datetime64[ns] 613s h datetime64[ns, US/Eastern] 613s dtype: object 613s actual 613s Size: 236B 613s Dimensions: (foo: 4) 613s Coordinates: 613s * foo (foo) object 32B 0 1 2 3 613s Data variables: 613s a (foo) object 32B 'a' 'b' 'c' 'd' 613s b (foo) int64 32B 1 2 3 4 613s c (foo) uint8 4B 3 4 5 6 613s d (foo) float64 32B 4.0 5.0 6.0 7.0 613s e (foo) bool 4B True False True False 613s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 613s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 613s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 613s a b c d e f g h 613s foo 613s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 613s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 613s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 613s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 613s Index([0, 1, 2, 3], dtype='object', name='foo') 613s a object 613s b int64 613s c uint8 613s d float64 613s e bool 613s f category 613s g datetime64[ns] 613s h datetime64[ns, US/Eastern] 613s dtype: object 613s xexpected 613s bar a b c d e f g h 613s foo 613s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 613s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 613s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 613s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 613s Index([0.0, 1.0, 2.0, 3.0], dtype='Float32', name='foo') 613s bar 613s a object 613s b int64 613s c uint8 613s d float64 613s e bool 613s f category 613s g datetime64[ns] 613s h datetime64[ns, US/Eastern] 613s dtype: object 613s actual 613s Size: 236B 613s Dimensions: (foo: 4) 613s Coordinates: 613s * foo (foo) object 32B 0.0 1.0 2.0 3.0 613s Data variables: 613s a (foo) object 32B 'a' 'b' 'c' 'd' 613s b (foo) int64 32B 1 2 3 4 613s c (foo) uint8 4B 3 4 5 6 613s d (foo) float64 32B 4.0 5.0 6.0 7.0 613s e (foo) bool 4B True False True False 613s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 613s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 613s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 613s a b c d e f g h 613s foo 613s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 613s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 613s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 613s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 613s Index([0.0, 1.0, 2.0, 3.0], dtype='object', name='foo') 613s a object 613s b int64 613s c uint8 613s d float64 613s e bool 613s f category 613s g datetime64[ns] 613s h datetime64[ns, US/Eastern] 613s dtype: object 613s xexpected 613s bar a b c d e f g h 613s foo 613s False a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 613s True b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 613s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 613s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 613s Index([False, True, True, True], dtype='boolean', name='foo') 613s bar 613s a object 613s b int64 613s c uint8 613s d float64 613s e bool 613s f category 613s g datetime64[ns] 613s h datetime64[ns, US/Eastern] 613s dtype: object 613s actual 613s Size: 236B 613s Dimensions: (foo: 4) 613s Coordinates: 613s * foo (foo) object 32B False True True True 613s Data variables: 613s a (foo) object 32B 'a' 'b' 'c' 'd' 613s b (foo) int64 32B 1 2 3 4 613s c (foo) uint8 4B 3 4 5 6 613s d (foo) float64 32B 4.0 5.0 6.0 7.0 613s e (foo) bool 4B True False True False 613s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 613s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 613s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 613s a b c d e f g h 613s foo 613s False a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 613s True b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 613s True b 2 4 5.0 False c 2013-01-02 2013-01-02 00:00:00-05:00 613s True b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 613s True c 3 5 6.0 True b 2013-01-03 2013-01-03 00:00:00-05:00 613s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 613s True c 3 5 6.0 True d 2013-01-03 2013-01-03 00:00:00-05:00 613s True d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 613s True d 4 6 7.0 False c 2013-01-04 2013-01-04 00:00:00-05:00 613s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 613s Index([False, True, True, True, True, True, True, True, True, True], dtype='object', name='foo') 613s a object 613s b int64 613s c uint8 613s d float64 613s e bool 613s f category 613s g datetime64[ns] 613s h datetime64[ns, US/Eastern] 613s dtype: object 613s xexpected 613s bar a b c d e f g h 613s foo 613s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 613s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 613s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 613s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 613s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='string', name='foo') 613s bar 613s a object 613s b int64 613s c uint8 613s d float64 613s e bool 613s f category 613s g datetime64[ns] 613s h datetime64[ns, US/Eastern] 613s dtype: object 613s actual 613s Size: 236B 613s Dimensions: (foo: 4) 613s Coordinates: 613s * foo (foo) object 32B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 613s Data variables: 613s a (foo) object 32B 'a' 'b' 'c' 'd' 613s b (foo) int64 32B 1 2 3 4 613s c (foo) uint8 4B 3 4 5 6 613s d (foo) float64 32B 4.0 5.0 6.0 7.0 613s e (foo) bool 4B True False True False 613s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 613s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 613s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 613s a b c d e f g h 613s foo 613s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 613s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 613s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 613s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 613s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 613s a object 613s b int64 613s c uint8 613s d float64 613s e bool 613s f category 613s g datetime64[ns] 613s h datetime64[ns, US/Eastern] 613s dtype: object 613s x................................. 613s 613s =============================== warnings summary =============================== 613s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 613s /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-ghofxu02' 613s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 613s 613s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 613s /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-kt_rdssb' 613s session.config.cache.set(STEPWISE_CACHE_DIR, []) 613s 613s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 613s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 613s ============================= slowest 30 durations ============================= 613s 0.40s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime-tz] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-object] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_bool] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[interval] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[complex64] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[period] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[timedelta] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint16] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string-python] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[float64] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[repeats] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint8] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-dtype] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int64] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[complex128] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[categorical] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_float] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[range] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[float32] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_uint] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint64] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint32] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int8] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int16] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_int] 613s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int32] 613s 0.02s call tests/generic/test_generic.py::TestGeneric::test_truncate_out_of_bounds[DataFrame] 613s 0.02s call tests/generic/test_duplicate_labels.py::test_pickle 613s ==== 978 passed, 105 skipped, 148 xfailed, 18 xpassed, 2 warnings in 8.38s ===== 613s rdjoqkol test state = true 613s + echo 'rdjoqkol test state = true' 613s + for TEST_SUBSET in $modpath/tests/* 613s + echo /usr/lib/python3/dist-packages/pandas/tests/groupby 613s + grep -q -e __pycache__ 613s + PANDAS_CI=1 613s + LC_ALL=C.UTF-8 613s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/groupby 614s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 614s 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" 614s 614s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 619s ============================= test session starts ============================== 619s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 619s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 619s rootdir: /usr/lib/python3/dist-packages/pandas 619s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 619s 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 619s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 619s collected 29434 items / 1832 deselected / 1 skipped / 27602 selected 619s 621s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_aggregate.py ...............................................................................................................................................................................................................................................................................................................................................x..x.......................................................................x....... 621s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_cython.py ........................................................................................................................................................................ 621s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 622s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_other.py ........................................ 622s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_corrwith.py . 622s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_describe.py ......................... 622s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_groupby_shift_diff.py ............................................... 622s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_is_monotonic.py ...... 622s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_nlargest_nsmallest.py ........................................... 623s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_nth.py .................................................................................................................................................................................................................................... 625s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_quantile.py ..................................................................................................x....x.......................................................................................................................................................................................................................... 629s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_rank.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 629s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_sample.py .............. 632s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_size.py .......x....x....x....x....x....x....x....x...............ss 632s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_skew.py . 634s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_value_counts.py ...........X......XXX...XXX.........XXX...XXX........................................ss.ss.ss.ss.ss.ss....XX..........................XXXXXXXXXXXXXXXX........XXXXXXXX...................................... 635s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_all_methods.py ......................................xx..............................................................................................ss..........ss..............ss...... 635s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_api.py ......s..s..............................s..s.......................... 636s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_apply.py .................................................................................................................................... 636s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_apply_mutate.py ..... 636s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_bin_groupby.py ...... 653s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_categorical.py .................................................................................................................................x......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ss.ss.ss.ssxxxxxx.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ssxxxxxx.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ssxxxxxx.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ssxxxxxx.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss.ss......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s........s........s........s........s........s........s........s...ss.sssss.ss.sssss.ss.sssss.ss.sssss.ss.sssss.ss.sssss.ss.sssss.ss.sssss...................ss.ss.ss.ss.ss.ss.................sxsx................................................................................sxsx................................................................................sxsx................................................................................sxsx.......................................x................................ 654s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_counting.py .................................ssss 654s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_cumulative.py ..................................................... 654s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_filters.py ............................ 665s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby.py ......................................s..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s...................s................................................................................................................... 692s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby_dropna.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxxxxxx.................................................. 693s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby_subclass.py .....s................................................................. 693s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_grouping.py ....................................................................................... 693s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_index_as_string.py .................. 694s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_indexing.py ............................................................................................................................................................................ 694s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_libgroupby.py ........................... 694s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_missing.py ......................... 695s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_numeric_only.py ..................xxx......ssssss..............................xxx.................................................................................................................................................................................................................................................................................................................................................................................. 696s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_pipe.py .. 728s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_raises.py ..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_reductions.py ...............................................................................................................................................................................................................................................................................................................ss........................................................................................................................................................ 730s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py ..............................s 730s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 746s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_transform.py ....................x.........................................................................................................................x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x....................................................................................x....................x............................................................................................................................................................................................................ 746s 746s =============================== warnings summary =============================== 746s tests/groupby/test_categorical.py::test_basic 746s /usr/lib/python3/dist-packages/numpy/_core/fromnumeric.py:84: FutureWarning: The behavior of DataFrame.sum with axis=None is deprecated, in a future version this will reduce over both axes and return a scalar. To retain the old behavior, pass axis=0 (or do not pass axis) 746s return reduction(axis=axis, out=out, **passkwargs) 746s 746s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 746s /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-r7gym8b_' 746s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 746s 746s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 746s /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-piwy52ny' 746s session.config.cache.set(STEPWISE_CACHE_DIR, []) 746s 746s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 746s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 746s ============================= slowest 30 durations ============================= 746s 0.49s call tests/groupby/test_raises.py::test_groupby_raises_category_on_category[by2-True-cumsum-False-agg] 746s 0.43s call tests/groupby/test_reductions.py::test_ops_general[sem-scipy_sem] 746s 0.28s call tests/groupby/test_groupby.py::test_empty_groupby[False-skew-agg-float-keys1-C] 746s 0.16s teardown tests/groupby/transform/test_transform.py::test_idxmin_idxmax_transform_args[False-False-idxmin] 746s 0.12s call tests/groupby/test_categorical.py::test_basic 746s 0.08s call tests/groupby/test_counting.py::test_count 746s 0.08s call tests/groupby/test_counting.py::TestCounting::test_ngroup_cumcount_pair 746s 0.07s call tests/groupby/test_timegrouper.py::TestGroupBy::test_timegrouper_with_reg_groups 746s 0.07s call tests/groupby/test_groupby_subclass.py::test_groupby_preserves_subclass[corrwith-obj0] 746s 0.06s call tests/groupby/test_groupby.py::test_groupby_multiindex_not_lexsorted 746s 0.06s call tests/groupby/test_categorical.py::test_datetime 746s 0.05s call tests/groupby/test_apply.py::test_apply_concat_preserve_names 746s 0.05s call tests/groupby/transform/test_transform.py::test_as_index_no_change[corrwith-keys1] 746s 0.05s call tests/groupby/methods/test_describe.py::test_frame_describe_multikey 746s 0.04s call tests/groupby/test_groupby.py::test_groupby_as_index_agg 746s 0.04s call tests/groupby/transform/test_transform.py::test_transform_fast 746s 0.04s call tests/groupby/test_apply.py::test_apply_corner_cases 746s 0.03s call tests/groupby/test_categorical.py::test_observed[False] 746s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-True-multi] 746s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-True-True-multi] 746s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-True-False-multi] 746s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-False-multi] 746s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-False-True-multi] 746s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-False-range] 746s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-True-range] 746s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-True-True-multi] 746s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-True-False-multi] 746s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-False-single] 746s 0.03s call tests/groupby/test_categorical.py::test_describe_categorical_columns 746s 0.03s call tests/groupby/transform/test_transform.py::test_transform_broadcast 746s = 26564 passed, 910 skipped, 1832 deselected, 90 xfailed, 39 xpassed, 3 warnings in 131.40s (0:02:11) = 749s rdjoqkol test state = true 749s + echo 'rdjoqkol test state = true' 749s + for TEST_SUBSET in $modpath/tests/* 749s + echo /usr/lib/python3/dist-packages/pandas/tests/indexes 749s + grep -q -e __pycache__ 749s + PANDAS_CI=1 749s + LC_ALL=C.UTF-8 749s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/indexes 749s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 749s 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" 749s 749s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 759s ============================= test session starts ============================== 759s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 759s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 759s rootdir: /usr/lib/python3/dist-packages/pandas 759s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 759s 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 759s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 759s collected 17010 items / 4 deselected / 17006 selected 759s 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_constructors.py .......s.. 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_formats.py .............. 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_indexing.py ............ 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_pickle.py . 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_reshape.py ..............s.... 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_setops.py ............................................................ 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_where.py . 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_append.py ....... 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_astype.py ........... 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_category.py ......................................... 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_constructors.py ..... 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_equals.py ......ss 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_fillna.py ... 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_formats.py .. 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_indexing.py ................................. 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_map.py ..................... 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_reindex.py ....... 759s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_setops.py .. 760s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_drop_duplicates.py ................................................................................................................ 760s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_equals.py ..................... 760s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_indexing.py ................ 760s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_is_monotonic.py . 760s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_nat.py ...................... 760s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_sort_values.py ................................................................................... 760s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_value_counts.py ............................................ 760s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_asof.py .. 760s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_astype.py ................................. 760s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_delete.py ....................... 760s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_factorize.py .................................................................................... 760s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_fillna.py .. 761s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_insert.py ............................................................................................................................................................................................. 761s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_isocalendar.py .. 761s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_map.py ..... 761s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_normalize.py ......... 761s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_repeat.py .................................................................................................................................................................................................................................................................................................................................................... 762s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_resolution.py .................................................................................................................................................................................... 762s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_round.py ...................................................................................................................................................................................................................... 763s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_shift.py ........................................................................................................................................ 763s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_snap.py ........................ 763s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_frame.py .. 763s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_julian_date.py ..... 763s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_period.py ........................................... 763s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_pydatetime.py .. 763s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_series.py . 763s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_tz_convert.py .................................... 764s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_tz_localize.py ............................................................................................................................................................ 764s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_unique.py ........................ 764s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_arithmetic.py .....................x 764s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_constructors.py ..................................................................................................................................................................................................................x...x.................................... 766s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_date_range.py .................................................................................................................................................................................................................................................................................................................................................. 766s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_datetime.py .................. 767s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_formats.py ........................................ 767s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_freq_attr.py .......................... 767s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................... 767s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_iter.py ............ 767s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_join.py ...................... 767s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_npfuncs.py . 767s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_ops.py ................ 768s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_partial_slicing.py .................................. 768s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_pickle.py ...... 768s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_reindex.py .. 775s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_scalar_compat.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 775s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_setops.py ................................................................................................................................ 775s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_timezones.py ........................................ 776s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_astype.py ....................................x........................................................................................................................... 777s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_constructors.py ............................................................................................................................................................................................................................................................................ssssssss.......................................s.................s.....s.....s.....s....................................ssssssss.......................................s.................s.....s.....s.....s.................................s 777s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_equals.py .... 777s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_formats.py ........... 777s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_indexing.py ............................................................................................................................................................................................................................................................................................ 778s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval.py .......x....x....x....x.................................................................................................................................................................................................................................. 779s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval_range.py ........................................................................................................................................................ 780s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval_tree.py .................................................................................................................................................................................................................... 780s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_join.py ... 780s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_pickle.py ... 780s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_setops.py ................................................................................. 780s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_analytics.py ...................................... 780s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_astype.py ... 780s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_compat.py ...... 780s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_constructors.py ..................................................................................s................. 780s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_conversion.py ...... 780s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_copy.py .......... 780s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_drop.py ............. 781s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_duplicates.py .................................................. 781s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_equivalence.py .............. 781s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_formats.py .............. 781s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_get_level_values.py ....... 781s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_get_set.py ................... 781s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_indexing.py ........................................................................................................................................... 781s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_integrity.py ................ 781s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_isin.py .............. 782s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_join.py ....................................................... 782s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_lexsort.py .. 782s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_missing.py ...x.. 782s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_monotonic.py ........... 782s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_names.py ............................... 782s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_partial_indexing.py ..... 782s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_pickle.py . 782s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_reindex.py ............ 782s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_reshape.py ........... 783s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_setops.py ............................................................................................................................................................................................................sss................................................................... 783s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_sorting.py .......................... 783s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_take.py ... 783s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_astype.py ................... 784s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_indexing.py ..............................................................................................................................................ss.......................................... 784s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_join.py ........... 784s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_numeric.py ................................................................................................ 784s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_setops.py .................... 784s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/object/test_astype.py .. 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/object/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.ss. 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_asfreq.py ............... 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_astype.py ............. 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_factorize.py .. 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_fillna.py . 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_insert.py ... 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_is_full.py . 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_repeat.py ...... 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_shift.py ...... 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_to_timestamp.py ........ 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_constructors.py .................................................................................................. 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_formats.py ................... 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_freq_attr.py . 786s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_indexing.py ......................................................................... 786s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_join.py ........... 786s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_monotonic.py .. 786s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_partial_slicing.py .............. 786s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_period.py .................................................................................................................................... 786s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_period_range.py ........................... 786s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_pickle.py .... 786s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_resolution.py ......... 786s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_scalar_compat.py ... 786s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_searchsorted.py ........ 787s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_setops.py .............. 787s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_tools.py ............ 787s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_constructors.py ............................. 787s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_indexing.py ............... 787s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_join.py .......... 787s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_range.py ................................................................................. 787s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_setops.py ................................................................... 788s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_any_index.py ......................................................................................................................s......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 790s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_base.py .........................................................................................................................................................................x.............................................................................ssss....ss..........ss......ss.................................................................................................................................ssss...........................................................................................................................................................................................................................................s.......................................................................................................s..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_common.py ...........................................................................................................................................................................................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.........................................................................................................................sssssssss...s....ss..........................xs.....................sss................................................sss....................................................................................s................s...............................................................................................................................................................................................................................................................................XX........................................... 792s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_datetimelike.py ........................................ 793s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_engines.py ......................................... 793s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_frozen.py .......... 793s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_index_new.py ............................................xxxxssss................................................................................................................ 793s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_indexing.py ......................................................ss...............................s.................................................................................................................................................................................................................................................................................................s........................ 795s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_numpy_compat.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ss..................... 797s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_old_base.py s...s...................sss.............................ssssssssss.s..........ss.................s.............s.....s..............s..sss..........................................................s.......................................................................ssssssss..s..sssssssss..s..sssssssss..s..sssssssss..s..sssssssss..s..s......................s..............................................s................s..............................s........................ssssssss....s.s...s.....s........sssssssss...s....s...sss...................................................................................................................ss......................ssssss.........................................................................................................................................................................s......................................................................................................................................................................................s...s...........s...s...........................................................................................s...s... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_setops.py ...........................................................................................................................................x........................................................................................................................................................................................................................................................................................................................................................................................................................X..................................................................x....................................................................................................X.........X...............................................................................................................X..........................................................................................................................................................................................................................................................................................................................................................s...........................................................................................................................ss..s.s...s...s.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssss....ss..........ss......ss..................................................................................................................................................................................................................................................................ssss....ss..........ss......ss................................................................................................................................................................................................................................................................s...........................................................................................................................................................................................ss 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_subclass.py . 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_astype.py ............... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_factorize.py .. 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_fillna.py . 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_insert.py ............... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_repeat.py . 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_shift.py ...... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_arithmetic.py ... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_constructors.py ..................... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_delete.py ... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_formats.py ..... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_freq_attr.py ........... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_indexing.py .................................... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_join.py ....... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_ops.py .......... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_pickle.py . 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_scalar_compat.py ........ 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_searchsorted.py ........ 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_setops.py ................................ 804s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_timedelta.py ... 805s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_timedelta_range.py ............................ 805s 805s =============================== warnings summary =============================== 805s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 805s /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-_ov0a7vf' 805s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 805s 805s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 805s /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-lhkxmtcf' 805s session.config.cache.set(STEPWISE_CACHE_DIR, []) 805s 805s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 805s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 805s ============================= slowest 30 durations ============================= 805s 0.33s call tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-tanh] 805s 0.32s call tests/indexes/period/test_indexing.py::TestGetItem::test_getitem_seconds 805s 0.18s call tests/indexes/datetimes/test_date_range.py::TestGenRangeGeneration::test_generate[B-offset0] 805s 0.18s call tests/indexes/ranges/test_setops.py::test_range_difference 805s 0.14s call tests/indexes/multi/test_indexing.py::test_pyint_engine 805s 0.14s teardown tests/indexes/timedeltas/test_timedelta_range.py::TestTimedeltas::test_timedelta_range_deprecated_freq[2.5T-5 hours-5 hours 8 minutes-expected_values1-150s] 805s 0.13s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[us] 805s 0.13s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[ns] 805s 0.12s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[ns] 805s 0.12s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[ms] 805s 0.12s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[ms] 805s 0.12s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[s] 805s 0.12s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[us] 805s 0.12s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[s] 805s 0.07s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[both-1] 805s 0.07s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[neither-1] 805s 0.06s call tests/indexes/datetimes/test_timezones.py::TestDatetimeIndexTimezones::test_with_tz[tz0] 805s 0.06s call tests/indexes/datetimes/methods/test_tz_localize.py::TestTZLocalize::test_dti_tz_localize_roundtrip[tzlocal()] 805s 0.05s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[right-1] 805s 0.05s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[left-1] 805s 0.05s call tests/indexes/multi/test_sorting.py::test_remove_unused_levels_large[datetime64[D]-str] 805s 0.05s call tests/indexes/period/test_partial_slicing.py::TestPeriodIndex::test_range_slice_seconds[period_range] 805s 0.04s call tests/indexes/datetimes/test_timezones.py::TestDatetimeIndexTimezones::test_with_tz[tz1] 805s 0.04s call tests/indexes/datetimes/methods/test_tz_localize.py::TestTZLocalize::test_dti_tz_localize_roundtrip[zoneinfo.ZoneInfo(key='US/Pacific')] 805s 0.04s call tests/indexes/test_setops.py::test_union_different_types[nullable_int-interval] 805s 0.04s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[both-10] 805s 0.04s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[neither-10] 805s 0.04s call tests/indexes/datetimes/test_constructors.py::TestDatetimeIndex::test_constructor_datetime64_tzformat[W-SUN] 805s 0.03s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[right-10] 805s 0.03s call tests/indexes/multi/test_integrity.py::test_consistency 805s = 16700 passed, 254 skipped, 4 deselected, 46 xfailed, 6 xpassed, 2 warnings in 55.22s = 807s + echo 'rdjoqkol test state = true' 807s rdjoqkol test state = true 807s + for TEST_SUBSET in $modpath/tests/* 807s + echo /usr/lib/python3/dist-packages/pandas/tests/indexing 807s + grep -q -e __pycache__ 807s + PANDAS_CI=1 807s + LC_ALL=C.UTF-8 807s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/indexing 808s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 808s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 808s 808s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 810s ============================= test session starts ============================== 810s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 810s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 810s rootdir: /usr/lib/python3/dist-packages/pandas 810s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 810s 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 810s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 810s collected 4389 items 810s 810s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/interval/test_interval.py .............................. 810s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/interval/test_interval_new.py ..................... 810s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_chaining_and_caching.py .. 810s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_datetime.py .. 810s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_getitem.py ............................................................................. 810s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_iloc.py ................ 812s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_indexing_slow.py .......... 812s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_loc.py ................................................................................................................................. 812s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_multiindex.py ................ 813s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_partial.py ............. 813s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_setitem.py ........................... 813s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_slice.py ............................. 813s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_sorted.py ......... 813s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_at.py ......................................... 814s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_categorical.py .................s................................................................................................ 815s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_chaining_and_caching.py .............................. 815s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_check_indexer.py ....................s.... 816s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_coercion.py ..........xxxxxxx...............................................................xx............................................xxxx....x............................................................xxxxx..................xx............................................................................................................................................................................................................x 816s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_datetime.py .........ss 816s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_floats.py ............................................................................................................................................... 816s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_iat.py ..... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_iloc.py .................................................................................................................................................................................................................. 817s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_indexers.py ...... 820s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_indexing.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 824s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_loc.py .............................................................................................................................x...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s...................................................................................................................................................................................................................................................................................................................................................................s.................................... 825s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_na_indexing.py .............................................................................................................................................................................................................................................................................. 825s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_partial.py .................................... 825s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_scalar.py ...................................... 825s 825s =============================== warnings summary =============================== 825s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 825s /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-1w_e7gvh' 825s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 825s 825s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 825s /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-ofy5xyf3' 825s session.config.cache.set(STEPWISE_CACHE_DIR, []) 825s 825s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 825s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 825s ============================= slowest 30 durations ============================= 825s 0.40s call tests/indexing/test_loc.py::TestLocBaseIndependent::test_loc_non_unique_memory_error[900000-100000] 825s 0.17s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-4] 825s 0.17s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-3] 825s 0.16s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-4] 825s 0.15s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-2] 825s 0.15s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-2] 825s 0.15s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-1] 825s 0.14s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-3] 825s 0.14s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-0] 825s 0.13s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_implicit_take2 825s 0.13s call tests/indexing/test_loc.py::TestLocBaseIndependent::test_loc_getitem_range_from_spmatrix[int64-coo_matrix] 825s 0.12s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_setting_entire_column 825s 0.12s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_implicit_take 825s 0.12s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-1] 825s 0.12s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-0] 825s 0.09s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_str 825s 0.05s call tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_groupby_example 825s 0.04s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_setitem 825s 0.03s teardown tests/indexing/test_scalar.py::TestMultiIndexScalar::test_multiindex_at_get_one_level 825s 0.03s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_getitem 825s 0.03s call tests/indexing/test_loc.py::TestLocSeries::test_loc_nonunique_masked_index 825s 0.02s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_doc_examples 825s 0.02s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_loc_axis_arguments 825s 0.02s call tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_setitem_multiindex3 825s 0.02s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_multiindex_slicers_non_unique 825s 0.01s call tests/indexing/test_loc.py::TestLocCallable::test_frame_loc_setitem_callable 825s 0.01s call tests/indexing/test_loc.py::TestLocBaseIndependent::test_loc_getitem_sparse_frame 825s 0.01s call tests/indexing/test_categorical.py::TestCategoricalIndex::test_loc_getitem_with_non_string_categories[None-idx_values17] 825s 0.01s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_multiindex_slicers_edges 825s 0.01s call tests/indexing/test_categorical.py::TestCategoricalIndex::test_loc_getitem_with_non_string_categories[None-idx_values28] 825s =========== 4360 passed, 6 skipped, 23 xfailed, 2 warnings in 17.22s =========== 826s + echo 'rdjoqkol test state = true' 826s + for TEST_SUBSET in $modpath/tests/* 826s + echo /usr/lib/python3/dist-packages/pandas/tests/interchange 826s rdjoqkol test state = true 826s + grep -q -e __pycache__ 826s + PANDAS_CI=1 826s + LC_ALL=C.UTF-8 826s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/interchange 826s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 826s 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" 826s 826s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 827s ============================= test session starts ============================== 827s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 827s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 827s rootdir: /usr/lib/python3/dist-packages/pandas 827s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 827s 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 827s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 827s collected 140 items 827s 827s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_impl.py ..sssssssss..............sssss........s..s..ssssssssssssssssssssssssssssssss. 827s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_spec_conformance.py ................ 827s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_utils.py ................sssssssssssssssssssssssssssssss 827s 827s =============================== warnings summary =============================== 827s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 827s /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-_ckw26nv' 827s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 827s 827s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 827s /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-s7kf35oa' 827s session.config.cache.set(STEPWISE_CACHE_DIR, []) 827s 827s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 827s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 827s ============================= slowest 30 durations ============================= 827s 0.02s call tests/interchange/test_impl.py::test_dataframe[4] 827s 0.01s call tests/interchange/test_impl.py::test_dataframe[3] 827s 0.01s call tests/interchange/test_impl.py::test_dataframe[0] 827s 0.01s call tests/interchange/test_impl.py::test_dataframe[1] 827s 0.01s call tests/interchange/test_impl.py::test_dataframe[2] 827s 0.01s call tests/interchange/test_impl.py::test_categorical_dtype[data0] 827s 827s (24 durations < 0.005s hidden. Use -vv to show these durations.) 827s ================== 61 passed, 79 skipped, 2 warnings in 0.56s ================== 827s + echo 'rdjoqkol test state = true' 827s + for TEST_SUBSET in $modpath/tests/* 827s + echo /usr/lib/python3/dist-packages/pandas/tests/internals 827s rdjoqkol test state = true 827s + grep -q -e __pycache__ 827s + PANDAS_CI=1 827s + LC_ALL=C.UTF-8 827s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/internals 828s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 828s 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" 828s 828s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 829s ============================= test session starts ============================== 829s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 829s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 829s rootdir: /usr/lib/python3/dist-packages/pandas 829s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 829s 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 829s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 829s collected 257 items 829s 829s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_api.py ......... 829s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_internals.py .................................................................................................................................................................................................................................................... 830s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_managers.py .... 830s 830s =============================== warnings summary =============================== 830s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 830s /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-oinxmn5z' 830s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 830s 830s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 830s /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-3w58mmvo' 830s session.config.cache.set(STEPWISE_CACHE_DIR, []) 830s 830s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 830s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 830s ============================= slowest 30 durations ============================= 830s 0.52s call tests/internals/test_managers.py::test_array_manager_depr_env_var[array] 830s 0.45s call tests/internals/test_managers.py::test_array_manager_depr_env_var[block] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-uint64] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_equals_block_order_different_dtypes[c:sparse;d:sparse_na;b:f8] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-int64] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-uint64] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-uint64] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-float64] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-int64] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-int64] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-int64] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-uint64] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_equals_block_order_different_dtypes[a:i8;e:dt;f:td;g:string] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-float64] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-float64] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-float64] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[0-int64] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category-i8] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: m8[ns]; b: i8-object] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: M8[ns]; b: bool-object] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category2-object] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: f8; b: i8-f8] 830s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[0-uint64] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: bool; b: i8-object] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category; b: category-i8] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: f4; b: i8; d: object-object] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: M8[ns]; b: category-object] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: m8[ns]; b: bool-object] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_equals_block_order_different_dtypes[a:i8;b:f8;c:c8;d:b] 830s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: f8-f8] 830s ======================= 257 passed, 2 warnings in 2.12s ======================== 831s + echo 'rdjoqkol test state = true' 831s + for TEST_SUBSET in $modpath/tests/* 831s rdjoqkol test state = true 831s + echo /usr/lib/python3/dist-packages/pandas/tests/io 831s + grep -q -e __pycache__ 831s + PANDAS_CI=1 831s + LC_ALL=C.UTF-8 831s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/io 832s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 832s 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" 832s 832s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 842s ============================= test session starts ============================== 842s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 842s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 842s rootdir: /usr/lib/python3/dist-packages/pandas 842s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 842s 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 842s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 842s collected 15519 items / 201 deselected / 2 skipped / 15318 selected 842s 842s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odf.py ..... 842s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odswriter.py .......... 843s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_openpyxl.py ...................................................... 859s ../../../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 861s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_style.py ...................................................................................................................................s 877s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_writers.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 877s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlrd.py ....... 878s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlsxwriter.py ..... 878s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_bar.py ..........................................................................................................................s 878s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_exceptions.py ... 879s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_format.py ......................................................................................................... 879s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_highlight.py ................................................................................................ 879s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_html.py ........................................................................................... 880s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_matplotlib.py ........................................................... 880s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_non_unique.py ......... 881s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_style.py ................................................................................................................................................................................................. 881s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_latex.py ............................................................................................................................................................ 881s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_string.py ..... 881s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_tooltip.py .... 881s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_console.py ........... 882s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_css.py ............................................................................................... 882s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_eng_formatting.py ....... 883s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_format.py .................................................................................................................................................................................. 883s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_ipython_compat.py ss..s 883s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_printing.py ......... 884s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_csv.py ..........s.................................................................................. 885s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_excel.py .......................................................................................................................................................................................................................................................................................................................................................................................................................... 886s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_html.py .....................................................................................................................................................................................................................................................................................................................................................................s................... 886s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_latex.py ............................................................................................ 886s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_markdown.py .......... 887s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_string.py ...............................................s........................................... 887s ../../../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....... 887s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_deprecated_kwargs.py . 888s ../../../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........................... 888s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_json_table_schema_ext_dtype.py ..................... 889s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_normalize.py ..................................................... 893s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_pandas.py ...........................................................................................................xxxx................................xxx........................................................................................................................................................................s........xxxxxxxxxxxxxxxxxx................................................................xx.............s.....x........ssssssssssssssssssssssssssssssss...sssss.s. 893s ../../../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........... 894s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_ujson.py ................................................................................................................................................................................................................... 895s ../../../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 895s ../../../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 895s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_data_list.py ...s...s...s...s 895s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_decimal.py ......ss...s 897s ../../../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 897s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_float.py ...s.......s.....................sss....x.....x...ss 897s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_index.py ......ss......ss...s............ssss...s...s...s...s...s...s...s 897s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_inf.py ......ss......ss...s 897s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_ints.py ...s............ssss...s......ss...s.........sss.........sss......ss......ss...s 897s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_iterator.py ...s...s...s.........sss...s 897s ../../../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 897s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_verbose.py ...s...s 898s ../../../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 902s ../../../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 902s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/dtypes/test_empty.py ...s...s...s...s...s...s...s...s........................ssssssss 902s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_c_parser_only.py .......................................................................... 902s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_comment.py ......ss.........sss...s...s...s..................ssssss......ssxx.s 905s ../../../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 905s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_concatenate_chunks.py ss 905s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_converters.py ...s............ssss...s...s...s......ss...s...s 905s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_dialect.py ...s...s...s......................................................ssssssssssssssssss..................ssssss 906s ../../../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 907s ../../../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 907s ../../../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 907s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_mangle_dupes.py ...s...s...s.........sss.........sss...s...s...s......ss 908s ../../../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 914s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py ................ssss.....ssssssssssssssssss 916s ../../../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 916s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_python_parser_only.py ..................................................................................... 916s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_quoting.py .........sss......ss...s..................ssssss............ssss...............sssss......ss......ss......ss 917s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_read_fwf.py ..........................................................................sss.. 917s ../../../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 917s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_textreader.py ..................................... 917s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_unsupported.py ..........s...s..xs...s 917s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_upcast.py ...........................ssss 917s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_parse_dates.py ......ss...s...s...s............ssss 918s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_strings.py ...s...s......ss......ss 918s ../../../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 920s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py ....x................ 921s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_categorical.py ..... 921s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_compat.py .... 921s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_complex.py ......... 921s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_errors.py ................ 927s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py ...................................................xxxxxxxxx................................................................................................................................... 927s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_keys.py .... 928s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_put.py ...................... 928s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_pytables_missing.py s 928s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_read.py ....................s 928s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_retain_attributes.py ..... 930s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_round_trip.py ..............................s 933s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_select.py ...x.....x............... 936s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py ............................................x..................... 936s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_subclass.py .. 936s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_time_series.py .... 937s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_timezones.py .......................................................................... 938s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_byteswap.py .......... 938s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas.py ... 939s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas7bdat.py ....................... 939s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_xport.py ....... 939s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_clipboard.py .......QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-ubuntu' 941s ...............................................................................................................................................................................................................................................................................................................................ssssss.. 942s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_common.py .......................................................s....s........ss.......s.........s.......s......................................... 944s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_compression.py ........................................................................................................................................ 944s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_fsspec.py .........ssssssssss..........s 944s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gbq.py .. 944s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gcs.py ssssssssssssssssss. 954s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py .........ssssss...............................................................................................................................s.................... 956s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py ...ss.......ss.......ss....ss 956s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_parquet.py .ssss.ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.ssssssss 963s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_pickle.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 963s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_s3.py .ss 963s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_spss.py .......s.. 986s ../../../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................ 995s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_stata.py ..............................................................................................................................................................................................................................................................................................................................................................................s.................................................................................................................................................................................................................................................... 995s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_to_xml.py ........................................................................s...............................................................ss 999s ../../../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. 999s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml_dtypes.py .............................................. 999s 999s =============================== warnings summary =============================== 999s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 999s /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-is5dqd8m' 999s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 999s 999s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 999s /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-d2537hzl' 999s session.config.cache.set(STEPWISE_CACHE_DIR, []) 999s 999s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 999s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 999s ============================= slowest 30 durations ============================= 999s 1.44s call tests/io/test_html.py::TestReadHtml::test_banklist_url[bs4] 999s 1.25s call tests/io/pytables/test_file_handling.py::test_complibs[blosc2-1] 999s 1.02s call tests/io/pytables/test_store.py::test_no_track_times 999s 0.95s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-5] 999s 0.90s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-4] 999s 0.80s call tests/io/test_html.py::TestReadHtml::test_banklist_no_match[bs4] 999s 0.61s call tests/io/pytables/test_select.py::test_select_iterator_complete_8014 999s 0.57s call tests/io/test_compression.py::test_with_missing_lzma_runtime 999s 0.54s call tests/io/test_compression.py::test_with_missing_lzma 999s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-gz_csv_responder-read_csv] 999s 0.50s teardown tests/io/parser/common/test_file_buffer_url.py::test_url[c_high] 999s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-html_responder-] 999s 0.50s teardown tests/io/xml/test_xml.py::test_url 999s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_bad_url_protocol[bs4] 999s 0.50s teardown tests/io/xml/test_xml.py::test_url_path_error[lxml] 999s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_bad_url_protocol[lxml] 999s 0.50s teardown tests/io/xml/test_xml.py::test_url_path_error[etree] 999s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[bz2-c-explicit] 999s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options1-html_responder-] 999s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[xz-c-infer] 999s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zstd-c-infer] 999s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[gzip-c-infer] 999s 0.50s teardown tests/io/parser/test_network.py::test_url_encoding_csv 999s 0.50s teardown tests/io/parser/common/test_file_buffer_url.py::test_url[c_low] 999s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zip-c-infer] 999s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[tar-python-explicit] 999s 0.50s teardown tests/io/xml/test_xml.py::test_parser_consistency_url[etree] 999s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_multiple_matches[lxml] 999s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[tar-c-infer] 999s 0.50s teardown tests/io/xml/test_xml.py::test_parser_consistency_url[lxml] 999s = 12149 passed, 3016 skipped, 201 deselected, 155 xfailed, 2 warnings in 167.40s (0:02:47) = 1002s rdjoqkol test state = true 1002s + echo 'rdjoqkol test state = true' 1002s + for TEST_SUBSET in $modpath/tests/* 1002s + echo /usr/lib/python3/dist-packages/pandas/tests/libs 1002s + grep -q -e __pycache__ 1002s + PANDAS_CI=1 1002s + LC_ALL=C.UTF-8 1002s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/libs 1003s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1003s 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" 1003s 1003s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1003s ============================= test session starts ============================== 1003s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1003s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1003s rootdir: /usr/lib/python3/dist-packages/pandas 1003s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1003s 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 1003s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1003s collected 2279 items 1003s 1006s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_hashtable.py ..............s.....................................................................s.............s.......................................................s.............s.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s................................................................................................................................................................................................. 1006s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_join.py ................. 1006s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_lib.py .................................................................................. 1006s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_libalgos.py ........ 1006s 1006s =============================== warnings summary =============================== 1006s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1006s /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-o5g7gi81' 1006s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1006s 1006s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1006s /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-pjgsqly3' 1006s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1006s 1006s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1006s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1006s ============================= slowest 30 durations ============================= 1006s 0.01s teardown tests/libs/test_libalgos.py::TestInfinity::test_infinity_against_nan 1006s 0.01s call tests/libs/test_hashtable.py::test_unique_label_indices 1006s 0.01s call tests/libs/test_libalgos.py::TestInfinity::test_infinity_sort 1006s 0.01s setup tests/libs/test_hashtable.py::TestHelpFunctions::test_mode_stable[True-int8] 1006s 1006s (26 durations < 0.005s hidden. Use -vv to show these durations.) 1006s ================= 2273 passed, 6 skipped, 2 warnings in 3.58s ================== 1007s + echo 'rdjoqkol test state = true' 1007s + for TEST_SUBSET in $modpath/tests/* 1007s rdjoqkol test state = true 1007s + echo /usr/lib/python3/dist-packages/pandas/tests/plotting 1007s + grep -q -e __pycache__ 1007s + PANDAS_CI=1 1007s + LC_ALL=C.UTF-8 1007s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/plotting 1008s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1008s 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" 1008s 1008s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1010s ============================= test session starts ============================== 1010s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1010s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1010s rootdir: /usr/lib/python3/dist-packages/pandas 1010s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1010s 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 1010s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1010s collected 1423 items / 212 deselected / 1211 selected 1010s 1031s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame.py ..................................................XX.........................s.s.s.s....................................................................................................x...................................................................................... 1036s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_color.py ......................................................................................... 1037s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_groupby.py ...... 1038s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_legend.py x..................... 1046s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_subplots.py .........x....................XX................................................................... 1047s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_hist_box_by.py ............................. 1047s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_backend.py .....s. 1051s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_boxplot_method.py .................................................... 1051s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_common.py ... 1053s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_converter.py ............................................ 1069s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_datetimelike.py ...............................................................................................................x..........................................x.......................x...............x..... 1069s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_groupby.py ................. 1075s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_hist_method.py ...........................x..x...................................................... 1084s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_misc.py s....................sss...................sss...................sss.................................. 1089s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_series.py ...............................XXXX.............................x........................................................x......................... 1089s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_style.py ...................................... 1089s 1089s =============================== warnings summary =============================== 1089s tests/plotting/frame/test_frame.py: 11 warnings 1089s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2650: RuntimeWarning: divide by zero encountered in scalar divide 1089s x_scale = 1.0 / inw 1089s 1089s tests/plotting/frame/test_frame.py: 11 warnings 1089s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2652: RuntimeWarning: invalid value encountered in scalar multiply 1089s self._mtx = np.array([[x_scale, 0.0, -inl*x_scale], 1089s 1089s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1089s /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-xkom82mx' 1089s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1089s 1089s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1089s /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-kaa_6ejy' 1089s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1089s 1089s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1089s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1089s ============================= slowest 30 durations ============================= 1089s 0.90s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[True] 1089s 0.73s call tests/plotting/test_converter.py::TestRegistration::test_dont_register_by_default 1089s 0.68s call tests/plotting/test_datetimelike.py::TestTSPlot::test_finder_daily 1089s 0.68s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[bar] 1089s 0.65s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[True] 1089s 0.63s call tests/plotting/test_converter.py::test_registry_mpl_resets 1089s 0.60s call tests/plotting/test_misc.py::TestSeriesPlots::test_bootstrap_plot 1089s 0.60s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharex_and_ax 1089s 0.55s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[False] 1089s 0.53s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[barh] 1089s 0.52s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[False] 1089s 0.51s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_ts_share_axes 1089s 0.47s call tests/plotting/test_datetimelike.py::TestTSPlot::test_line_plot_period_mlt_series[4D] 1089s 0.44s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_kde_df 1089s 0.43s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[False-None-1-layout1] 1089s 0.42s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[line] 1089s 0.39s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharey_and_ax 1089s 0.39s call tests/plotting/test_datetimelike.py::TestTSPlot::test_frame_inferred 1089s 0.39s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[True-UserWarning-3-layout0] 1089s 0.38s call tests/plotting/test_hist_method.py::TestDataFrameGroupByPlots::test_histtype_argument[barstacked-True] 1089s 0.36s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_df_gridspec_patterns_vert_horiz 1089s 0.34s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df 1089s 0.33s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data0] 1089s 0.31s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data1] 1089s 0.30s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_constrained_layout 1089s 0.30s call tests/plotting/test_datetimelike.py::TestTSPlot::test_line_plot_datetime_frame[D] 1089s 0.30s call tests/plotting/test_boxplot_method.py::TestDataFramePlots::test_stacked_boxplot_set_axis 1089s 0.27s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_scatter 1089s 0.27s call tests/plotting/test_misc.py::test_savefig[index0-data0-hexbin] 1089s 0.27s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_bar_bottom_left_subplots 1089s = 1177 passed, 15 skipped, 212 deselected, 11 xfailed, 8 xpassed, 24 warnings in 81.40s (0:01:21) = 1090s + echo 'rdjoqkol test state = true' 1090s + for TEST_SUBSET in $modpath/tests/* 1090s + echo /usr/lib/python3/dist-packages/pandas/tests/reductions 1090s + grep -q -e __pycache__ 1090s rdjoqkol test state = true 1090s + PANDAS_CI=1 1090s + LC_ALL=C.UTF-8 1090s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reductions 1091s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1091s 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" 1091s 1091s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1091s ============================= test session starts ============================== 1091s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1091s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1091s rootdir: /usr/lib/python3/dist-packages/pandas 1091s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1091s 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 1091s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1091s collected 550 items 1091s 1092s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_reductions.py .....................................................................................................................................................................................................................................................................................................................................s....................................................................................................................................... 1093s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_stat_reductions.py ......................................................................................... 1093s 1093s =============================== warnings summary =============================== 1093s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1093s /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-wub7ul6m' 1093s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1093s 1093s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1093s /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-xwy5u_uh' 1093s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1093s 1093s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1093s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1093s ============================= slowest 30 durations ============================= 1093s 0.43s call tests/reductions/test_stat_reductions.py::TestSeriesStatReductions::test_skew 1093s 0.05s call tests/reductions/test_reductions.py::TestReductions::test_same_tz_min_max_axis_1[max-a] 1093s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-True] 1093s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-True] 1093s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-False] 1093s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-False] 1093s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-True] 1093s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-False] 1093s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-False] 1093s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-True] 1093s 0.01s call tests/reductions/test_stat_reductions.py::TestSeriesStatReductions::test_var_std 1093s 1093s (19 durations < 0.005s hidden. Use -vv to show these durations.) 1093s ================== 549 passed, 1 skipped, 2 warnings in 2.16s ================== 1093s rdjoqkol test state = true 1093s + echo 'rdjoqkol test state = true' 1093s + for TEST_SUBSET in $modpath/tests/* 1093s + echo /usr/lib/python3/dist-packages/pandas/tests/resample 1093s + grep -q -e __pycache__ 1093s + PANDAS_CI=1 1093s + LC_ALL=C.UTF-8 1093s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/resample 1094s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1094s 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" 1094s 1094s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1095s ============================= test session starts ============================== 1095s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1095s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1095s rootdir: /usr/lib/python3/dist-packages/pandas 1095s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1095s 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 1095s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1095s collected 4179 items 1095s 1099s ../../../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............................................................................................................................................................................................................................................................................................................................................................................................................................................................. 1119s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_datetime_index.py ................................................................................ssss............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...x...x...x..........................................................................................................................................................................................................................................................................................................................................................................ss 1123s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_period_index.py .................................................................................................................................................................................................................................................................................................................................................................................................................................x.................................................................................. 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resample_api.py ..................................................................................................................................................................................................... 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resampler_grouper.py s................................................... 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_time_grouper.py .........................x...................... 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_timedelta.py .......................s 1125s 1125s =============================== warnings summary =============================== 1125s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1125s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-ssgxrau1' 1125s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1125s 1125s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1125s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-6ogr3hyz' 1125s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1125s 1125s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1125s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1125s ============================= slowest 30 durations ============================= 1125s 0.19s call tests/resample/test_datetime_index.py::test_resample_dtype_coercion[s] 1125s 0.14s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-2] 1125s 0.14s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-43200-s-0.5-D-1] 1125s 0.14s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-86400-s-1-D-2] 1125s 0.13s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-3] 1125s 0.13s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-86400-s-1-D-3] 1125s 0.13s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-30-s-0.5-Min-3] 1125s 0.13s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-43200-s-0.5-D-1] 1125s 0.13s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-3600-s-1-h-2] 1125s 0.13s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-86400-s-1-D-3] 1125s 0.13s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-3600-s-1-h-3] 1125s 0.13s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-3600-s-1-h-3] 1125s 0.13s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-1] 1125s 0.13s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-21600-s-0.25-D-2] 1125s 0.12s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-1] 1125s 0.12s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-21600-s-0.25-D-3] 1125s 0.12s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-86400-s-1-D-1] 1125s 0.12s call tests/resample/test_period_index.py::TestPeriodIndex::test_annual_upsample_cases[D-D-start-bfill-OCT] 1125s 0.12s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-86400-s-1-D-3] 1125s 0.12s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-60-s-1-Min-1] 1125s 0.12s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-43200-s-0.5-D-1] 1125s 0.12s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-3600-s-1-h-2] 1125s 0.11s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-3] 1125s 0.11s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-21600-s-0.25-D-1] 1125s 0.11s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-30-s-0.5-Min-1] 1125s 0.11s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-3600-s-1-h-2] 1125s 0.11s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-86400-s-1-D-1] 1125s 0.11s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-86400-s-1-D-1] 1125s 0.11s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-86400-s-1-D-2] 1125s 0.11s call tests/resample/test_datetime_index.py::test_resample_ohlc[ms] 1125s =========== 4117 passed, 8 skipped, 54 xfailed, 2 warnings in 31.36s =========== 1126s rdjoqkol test state = true 1126s + echo 'rdjoqkol test state = true' 1126s + for TEST_SUBSET in $modpath/tests/* 1126s + echo /usr/lib/python3/dist-packages/pandas/tests/reshape 1126s + grep -q -e __pycache__ 1126s + PANDAS_CI=1 1126s + LC_ALL=C.UTF-8 1126s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reshape 1127s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1127s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1127s 1127s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1129s ============================= test session starts ============================== 1129s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1129s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1129s rootdir: /usr/lib/python3/dist-packages/pandas 1129s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1129s 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 1129s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1129s collected 2610 items / 1 deselected / 2609 selected 1129s 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append.py .................................................................................. 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append_common.py ...........................sssssssss....................................................... 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_categorical.py ............. 1130s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_concat.py .............................................................................................. 1130s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_dataframe.py ..................... 1130s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_datetimes.py ..................................................................................................x......... 1130s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_empty.py .....................s.....s.....s.....s.....s.......... 1131s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_index.py ............................................................. 1131s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_invalid.py ....... 1131s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_series.py ............. 1131s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_sort.py .......... 1131s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_join.py .......s..........................s....................................... 1136s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss..............................................................................................................................................................................................................................ss..........................................................................................................................................................................................................................................................................ssss........ 1137s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_asof.py .s...................................................................................................s.....................s....s.s.s.s.............sss.. 1137s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_cross.py ................. 1137s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_index_as_string.py ................................................................................ 1138s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_ordered.py ..................... 1138s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_multi.py .....s.s.................................. 1139s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_crosstab.py ..................................... 1139s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_cut.py ..................................................................................................................................... 1140s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_from_dummies.py ......................................... 1141s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_get_dummies.py ...................................................................................................................................................ss 1141s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_melt.py ..........................................................s 1144s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot.py ...........................................................................xx................................................................................................. 1144s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot_multilevel.py .......... 1144s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_qcut.py ................................................................................ 1144s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_union_categoricals.py .......................................... 1144s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_util.py ................. 1144s 1144s =============================== warnings summary =============================== 1144s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1144s /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-74pu605h' 1144s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1144s 1144s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1144s /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-gq884na1' 1144s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1144s 1144s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1144s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1144s ============================= slowest 30 durations ============================= 1144s 0.09s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_multi_functions 1144s 0.09s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize 1144s 0.08s call tests/reshape/test_pivot.py::TestPivotTable::test_margins 1144s 0.08s call tests/reshape/merge/test_join.py::TestJoin::test_full_outer_join 1144s 0.08s call tests/reshape/merge/test_merge.py::TestMerge::test_merge_non_unique_indexes 1144s 0.07s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_dropna6 1144s 0.07s call tests/reshape/concat/test_concat.py::TestConcatenate::test_concat_order 1144s 0.07s call tests/reshape/merge/test_join.py::TestJoin::test_right_outer_join 1144s 0.06s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_normalize 1144s 0.05s call tests/reshape/test_crosstab.py::test_categoricals[category-category] 1144s 0.05s call tests/reshape/test_crosstab.py::test_categoricals[int64-category] 1144s 0.04s call tests/reshape/test_crosstab.py::test_categoricals[category-int64] 1144s 0.04s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize_arrays 1144s 0.04s call tests/reshape/merge/test_multi.py::TestMergeMulti::test_compress_group_combinations 1144s 0.04s call tests/reshape/test_crosstab.py::test_categoricals[int64-int64] 1144s 0.04s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper 1144s 0.03s call tests/reshape/test_pivot.py::TestPivotTable::test_daily 1144s 0.03s call tests/reshape/merge/test_join.py::TestJoin::test_left_outer_join 1144s 0.03s call tests/reshape/merge/test_merge.py::TestMerge::test_validation 1144s 0.03s call tests/reshape/merge/test_merge.py::TestMerge::test_indicator 1144s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_margins_set_margin_name 1144s 0.03s call tests/reshape/merge/test_merge.py::TestMerge::test_merge_indicator_result_integrity 1144s 0.03s call tests/reshape/test_qcut.py::test_qcut_binning_issues 1144s 0.03s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_table_margins_name_with_aggfunc_list 1144s 0.03s call tests/reshape/merge/test_merge.py::TestMerge::test_merge_left_empty_right_notempty 1144s 0.03s call tests/reshape/merge/test_merge.py::TestMerge::test_merge_non_unique_index_many_to_many 1144s 0.03s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper_double 1144s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_with_ordered_categorical_column 1144s 0.03s call tests/reshape/merge/test_multi.py::TestMergeMulti::test_left_join_multi_index[True-False] 1144s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[list] 1144s ==== 2561 passed, 45 skipped, 1 deselected, 3 xfailed, 2 warnings in 17.59s ==== 1145s rdjoqkol test state = true 1145s + echo 'rdjoqkol test state = true' 1145s + for TEST_SUBSET in $modpath/tests/* 1145s + echo /usr/lib/python3/dist-packages/pandas/tests/scalar 1145s + grep -q -e __pycache__ 1145s + PANDAS_CI=1 1145s + LC_ALL=C.UTF-8 1145s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/scalar 1146s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1146s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1146s 1146s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1149s ============================= test session starts ============================== 1149s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1149s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1149s rootdir: /usr/lib/python3/dist-packages/pandas 1149s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1149s 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 1149s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1149s collected 4353 items 1149s 1149s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_arithmetic.py ............................................ 1149s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_constructors.py ......... 1149s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_contains.py ................ 1149s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_formats.py . 1150s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_interval.py ............................................ 1150s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_overlaps.py ................................................................................................................................................................. 1150s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_arithmetic.py .................................................................................... 1150s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_asfreq.py ....................... 1150s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_period.py ............................................................................................................................................................................................................................................................................................................... 1151s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_na_scalar.py .....................................................................................ss.....ss.....ss................................................................................................................................................................................ 1151s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_nat.py ........................................................................................................................s............s............................................................................................................................................................................................................................ 1151s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_as_unit.py .... 1152s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_round.py ................... 1152s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_arithmetic.py ................................................................................................................................ 1152s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_constructors.py ................................................................................................................................................................................................................................................................................................................... 1152s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_formats.py .............. 1156s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_timedelta.py .................................................................x............ 1156s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_as_unit.py .... 1156s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_normalize.py ................................................................................................................................................................. 1156s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_replace.py ............................................................................................................................ 1157s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_round.py ....................................................................................................................................................................................... 1157s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_timestamp_method.py . 1157s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_julian_date.py ..... 1157s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_pydatetime.py ....... 1157s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_convert.py ............................................................................... 1158s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_localize.py ................................................................................................................................................................................................. 1158s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_arithmetic.py ............................................................................................................. 1158s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_comparisons.py .............................. 1158s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_constructors.py ..................................................................xxx.............................................................. 1158s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_formats.py ........................................................................... 1162s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timestamp.py .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................................................................................................................... 1162s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timezones.py .................... 1162s 1162s =============================== warnings summary =============================== 1162s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1162s /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-eb2iyl95' 1162s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1162s 1162s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1162s /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-e9rxyrq6' 1162s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1162s 1162s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1162s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1162s ============================= slowest 30 durations ============================= 1162s 3.33s call tests/scalar/timedelta/test_timedelta.py::TestTimedeltas::test_hash_equality_invariance 1162s 0.16s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[round] 1162s 0.16s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[round] 1162s 0.15s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[floor] 1162s 0.14s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[floor] 1162s 0.13s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[ceil] 1162s 0.13s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[ceil] 1162s 0.11s call tests/scalar/timestamp/test_timestamp.py::TestTimestampProperties::test_dow_parametric 1162s 0.03s teardown tests/scalar/timestamp/test_timezones.py::TestTimestampTZOperations::test_timestamp_timetz_equivalent_with_datetime_tz[zoneinfo.ZoneInfo(key='UTC')] 1162s 0.01s call tests/scalar/test_nat.py::test_nat_vector_field_access 1162s 0.01s call tests/scalar/period/test_period.py::TestPeriodMethods::test_to_timestamp 1162s 0.01s call tests/scalar/period/test_arithmetic.py::TestPeriodArithmetic::test_period_add_offset 1162s 0.01s call tests/scalar/timestamp/test_timestamp.py::TestNonNano::test_pickle['UTC+01:15'-us] 1162s 0.01s call tests/scalar/test_nat.py::test_nat_arithmetic_td64_vector[Series-right_minus_left] 1162s 1162s (16 durations < 0.005s hidden. Use -vv to show these durations.) 1162s =========== 4340 passed, 8 skipped, 5 xfailed, 2 warnings in 15.91s ============ 1163s rdjoqkol test state = true 1163s + echo 'rdjoqkol test state = true' 1163s + for TEST_SUBSET in $modpath/tests/* 1163s + echo /usr/lib/python3/dist-packages/pandas/tests/series 1163s + grep -q -e __pycache__ 1163s + PANDAS_CI=1 1163s + LC_ALL=C.UTF-8 1163s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/series 1163s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1163s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1163s 1163s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1169s ============================= test session starts ============================== 1169s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1169s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1169s rootdir: /usr/lib/python3/dist-packages/pandas 1169s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1169s 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 1169s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1169s collected 13032 items / 2 skipped 1169s 1169s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_cat_accessor.py ................... 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_dt_accessor.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_sparse_accessor.py . 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_str_accessor.py .. 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_datetime.py ................. 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_delitem.py .... 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_get.py ............ 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_getitem.py .............................................................................................. 1179s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1179s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_mask.py .... 1179s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_set_value.py ... 1184s ../../../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................................................................................................................................................................................................... 1184s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_take.py .... 1185s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_where.py ......................................................................................................................................................................................................... 1185s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_xs.py ...... 1185s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_add_prefix_suffix.py ... 1185s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_align.py ............................................................................................................... 1185s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_argsort.py ......... 1185s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_asof.py ....... 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_astype.py ........................................................s....s..........................................................................x........sssssssss.................s 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_autocorr.py . 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_between.py ....... 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_case_when.py ........... 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_clip.py ....s.....s.....s.....s.....s.....s.....s.....s.....s.....s............ 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine.py . 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine_first.py .............................. 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_compare.py ............ 1188s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_convert_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s......ss 1188s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_copy.py .......... 1188s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_count.py ... 1189s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_cov_corr.py ................ 1189s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_describe.py ...................................................... 1189s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_diff.py ....... 1189s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop.py ............................. 1190s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop_duplicates.py ..................................................................ssssss.............................................................................................................................................................................................................................................................................................................ss 1190s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dropna.py ........... 1190s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dtypes.py . 1190s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_duplicated.py .................. 1190s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_equals.py ..................................................... 1190s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_explode.py ...............ssss 1191s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_fillna.py ....................x.x.x................................................................................................................................. 1191s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_get_numeric_data.py . 1191s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_head_tail.py . 1191s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_infer_objects.py ....... 1191s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_info.py ........x..... 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_interpolate.py x.........................................................................................................................................................................................................x.x............. 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_monotonic.py .. 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_unique.py ........ 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isin.py ......................................... 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isna.py .. 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_item.py . 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_map.py ......ss...................................xxx....................................................... 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_matmul.py . 1193s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nlargest.py ................................................................. 1193s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nunique.py .. 1193s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pct_change.py .............. 1193s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pop.py . 1193s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_quantile.py ........................................ 1194s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rank.py .......................................................................................................ssssssssssssssssssssssssssssss........................................................ssssssssssssssss.....ss.....ss.....ss.....ss.....ss.....................................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss. 1194s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex.py ................................... 1194s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex_like.py .. 1194s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename.py ................ 1194s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename_axis.py ..... 1194s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_repeat.py ... 1194s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_replace.py ...........................s.......................................................................... 1194s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reset_index.py ........s...... 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_round.py ......................................................................................... 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_searchsorted.py ........ 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_set_name.py .. 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_size.py ....... 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_index.py .............................................. 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_values.py .............. 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_csv.py ................................... 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_dict.py ...... 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_frame.py ... 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_numpy.py ...s. 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tolist.py ..........sss 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_truncate.py .... 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tz_localize.py ................................................................ 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unique.py ....... 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unstack.py ....... 1195s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_update.py ....................s..... 1196s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_value_counts.py ................... 1196s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_values.py ... 1196s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_view.py .................................................. 1196s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_api.py ................................s.......................................................................................................................................................... 1205s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...............................x............. 1206s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_constructors.py ......................................................................................................................................................................................................................................x.........x............................................................................................s.................................xx.................................................sssssss.s...................... 1206s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_cumulative.py ....................................... 1207s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_formats.py .................................................. 1207s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_iteration.py ....... 1207s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_logical_ops.py ..........................xs 1207s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_missing.py ...x.. 1207s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_npfuncs.py ....s 1207s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_reductions.py ..............s............... 1207s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_subclass.py ......... 1209s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_ufunc.py .....................................................................xxxx........................................................................................................................................ 1209s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_unary.py .......................... 1209s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_validate.py ............................ 1209s 1209s =============================== warnings summary =============================== 1209s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1209s /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-1p00wx4k' 1209s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1209s 1209s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1209s /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-u5c2ca0j' 1209s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1209s 1209s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1209s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1209s ============================= slowest 30 durations ============================= 1209s 0.43s call tests/series/methods/test_cov_corr.py::TestSeriesCorr::test_corr[float64] 1209s 0.40s call tests/series/test_formats.py::TestSeriesRepr::test_latex_repr 1209s 0.37s call tests/series/methods/test_rank.py::test_pct_max_many_rows 1209s 0.32s call tests/series/test_arithmetic.py::TestNamePreservation::test_series_ops_name_retention[numexpr-names3-truediv-True-Series] 1209s 0.21s call tests/series/methods/test_convert_dtypes.py::TestSeriesConvertDtypes::test_convert_dtypes[test_cases14-params5] 1209s 0.14s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[br_FR.UTF-8] 1209s 0.07s teardown tests/series/test_validate.py::test_validate_bool_args[5.0-drop_duplicates] 1209s 0.06s call tests/series/methods/test_isin.py::TestSeriesIsIn::test_isin 1209s 0.03s call tests/series/test_api.py::TestSeriesMisc::test_inspect_getmembers 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[xh_ZA.UTF-8] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[es_SV.UTF-8] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[es_PY.UTF-8] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_IQ.ISO8859-6] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_IQ.UTF-8] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[my_MM.UTF-8] 1209s 0.02s call tests/series/accessors/test_cat_accessor.py::TestCatAccessor::test_dt_accessor_api_for_categorical[idx1] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[nan_TW.UTF-8@latin] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[es_US.ISO8859-1] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[yue_HK.UTF-8] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_OM.UTF-8] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[byn_ER.UTF-8] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ca_ES.UTF-8] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[es_SV.ISO8859-1] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[mt_MT.UTF-8] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[zh_HK.UTF-8] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ca_FR.UTF-8] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[nb_NO.ISO8859-1] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ca_ES.ISO8859-1] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_MA.ISO8859-6] 1209s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[gv_GB.ISO8859-1] 1209s ========= 12405 passed, 606 skipped, 23 xfailed, 2 warnings in 45.43s ========== 1210s rdjoqkol test state = true 1210s + echo 'rdjoqkol test state = true' 1210s + for TEST_SUBSET in $modpath/tests/* 1210s + echo /usr/lib/python3/dist-packages/pandas/tests/strings 1210s + grep -q -e __pycache__ 1210s + PANDAS_CI=1 1210s + LC_ALL=C.UTF-8 1210s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/strings 1211s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1211s 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" 1211s 1211s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1212s ============================= test session starts ============================== 1212s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1212s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1212s rootdir: /usr/lib/python3/dist-packages/pandas 1212s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1212s 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 1212s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1212s collected 3604 items 1212s 1217s ../../../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 1218s ../../../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 1218s ../../../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...................................... 1219s ../../../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 1219s ../../../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 1219s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_get_dummies.py ..ss...ss. 1220s ../../../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 1220s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_string_array.py ...............................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss....ssss....ssss.s 1221s ../../../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....... 1221s 1221s =============================== warnings summary =============================== 1221s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1221s /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-retn0rdj' 1221s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1221s 1221s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1221s /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-nmcbhbdp' 1221s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1221s 1221s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1221s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1221s ============================= slowest 30 durations ============================= 1221s 0.10s setup tests/strings/test_strings.py::test_count_mixed_object 1221s 0.02s call tests/strings/test_strings.py::test_empty_str_methods[string[python]] 1221s 0.02s teardown tests/strings/test_strings.py::test_series_str_decode 1221s 0.01s call tests/strings/test_extract.py::test_extract_expand_capture_groups[string[python]] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract[string[python]] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data7-names7] 1221s 0.01s call tests/strings/test_strings.py::test_empty_str_methods[object] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data3-names3] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data6-names6] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data5-names5] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract_subject_index[object] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data2-names2] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data7-names7] 1221s 0.01s call tests/strings/test_extract.py::test_extract_series[string[python]-series_name] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data1-names1] 1221s 0.01s call tests/strings/test_extract.py::test_extract_expand_capture_groups[object] 1221s 0.01s call tests/strings/test_extract.py::test_extract_series[string[python]-None] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract_subject_index[string[python]] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data4-names4] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data6-names6] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data2-names2] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data5-names5] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data0-names0] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data3-names3] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract[object] 1221s 0.01s call tests/strings/test_extract.py::test_extractall[string[python]] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data1-names1] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data0-names0] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data4-names4] 1221s 0.01s call tests/strings/test_extract.py::test_extractall_stringindex[object] 1221s ========== 2704 passed, 887 skipped, 13 xfailed, 2 warnings in 9.20s =========== 1221s + echo 'rdjoqkol test state = true' 1221s + for TEST_SUBSET in $modpath/tests/* 1221s rdjoqkol test state = true 1221s + echo /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 1221s + grep -q -e __pycache__ 1221s + PANDAS_CI=1 1221s + LC_ALL=C.UTF-8 1221s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 1222s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1222s 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" 1222s 1222s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1222s ============================= test session starts ============================== 1222s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1222s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1222s rootdir: /usr/lib/python3/dist-packages/pandas 1222s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1222s 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 1222s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1222s collected 8 items 1222s 1222s ../../../usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py ........ 1222s 1222s =============================== warnings summary =============================== 1222s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1222s /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-6u8filme' 1222s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1222s 1222s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1222s /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-5g4ytjou' 1222s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1222s 1222s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1222s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1222s ============================= slowest 30 durations ============================= 1222s 1222s (24 durations < 0.005s hidden. Use -vv to show these durations.) 1222s ======================== 8 passed, 2 warnings in 0.15s ========================= 1222s + echo 'rdjoqkol test state = true' 1222s + for TEST_SUBSET in $modpath/tests/* 1222s + echo /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 1222s + grep -q -e __pycache__ 1222s rdjoqkol test state = true 1222s + PANDAS_CI=1 1222s + LC_ALL=C.UTF-8 1222s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 1223s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1223s 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" 1223s 1223s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1224s ============================= test session starts ============================== 1224s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1224s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1224s rootdir: /usr/lib/python3/dist-packages/pandas 1224s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1224s 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 1224s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1224s collected 471 items 1224s 1228s ../../../usr/lib/python3/dist-packages/pandas/tests/test_algos.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1228s 1228s =============================== warnings summary =============================== 1228s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1228s /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-83rbcdaw' 1228s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1228s 1228s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1228s /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-iw9mcsb5' 1228s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1228s 1228s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1228s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1228s ============================= slowest 30 durations ============================= 1228s 2.54s call tests/test_algos.py::TestRank::test_pct_max_many_rows 1228s 0.56s call tests/test_algos.py::TestRank::test_scipy_compat[arr0] 1228s 0.02s call tests/test_algos.py::TestDuplicated::test_datetime_likes 1228s 0.01s call tests/test_algos.py::TestIsin::test_large 1228s 0.01s call tests/test_algos.py::TestUnique::test_object_refcount_bug 1228s 0.01s call tests/test_algos.py::TestIsin::test_same_nan_is_in_large_series 1228s 0.01s call tests/test_algos.py::TestValueCounts::test_value_counts_nat 1228s 0.01s call tests/test_algos.py::TestUnique::test_dtype_preservation[bytes1] 1228s 1228s (22 durations < 0.005s hidden. Use -vv to show these durations.) 1228s ======================= 471 passed, 2 warnings in 4.39s ======================== 1228s rdjoqkol test state = true 1228s + echo 'rdjoqkol test state = true' 1228s + for TEST_SUBSET in $modpath/tests/* 1228s + echo /usr/lib/python3/dist-packages/pandas/tests/test_common.py 1228s + grep -q -e __pycache__ 1228s + PANDAS_CI=1 1228s + LC_ALL=C.UTF-8 1228s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_common.py 1229s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1229s 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" 1229s 1229s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1229s ============================= test session starts ============================== 1229s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1229s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1229s rootdir: /usr/lib/python3/dist-packages/pandas 1229s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1229s 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 1229s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1229s collected 128 items 1229s 1230s ../../../usr/lib/python3/dist-packages/pandas/tests/test_common.py ...............x.x.............................................................................................................. 1230s 1230s =============================== warnings summary =============================== 1230s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1230s /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-ny_vaia2' 1230s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1230s 1230s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1230s /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-vu7c4bwd' 1230s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1230s 1230s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1230s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1230s ============================= slowest 30 durations ============================= 1230s 0.51s call tests/test_common.py::test_bz2_missing_import 1230s 0.40s call tests/test_common.py::test_str_size 1230s 0.01s call tests/test_common.py::test_serializable[obj18] 1230s 1230s (27 durations < 0.005s hidden. Use -vv to show these durations.) 1230s ================== 126 passed, 2 xfailed, 2 warnings in 1.33s ================== 1231s rdjoqkol test state = true 1231s + echo 'rdjoqkol test state = true' 1231s + for TEST_SUBSET in $modpath/tests/* 1231s + echo /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 1231s + grep -q -e __pycache__ 1231s + PANDAS_CI=1 1231s + LC_ALL=C.UTF-8 1231s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 1231s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1231s 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" 1231s 1231s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1232s ============================= test session starts ============================== 1232s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1232s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1232s rootdir: /usr/lib/python3/dist-packages/pandas 1232s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1232s 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 1232s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1232s collected 26 items 1232s 1237s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sx.........s. 1237s 1237s =============================== warnings summary =============================== 1237s tests/test_downstream.py::test_dask 1237s /usr/lib/python3/dist-packages/dask/dataframe/__init__.py:49: FutureWarning: 1237s Dask dataframe query planning is disabled because dask-expr is not installed. 1237s 1237s You can install it with `pip install dask[dataframe]` or `conda install dask`. 1237s This will raise in a future version. 1237s 1237s warnings.warn(msg, FutureWarning) 1237s 1237s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1237s /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-a8wyni73' 1237s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1237s 1237s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1237s /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-rxwftvaz' 1237s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1237s 1237s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1237s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1237s ============================= slowest 30 durations ============================= 1237s 2.23s call tests/test_downstream.py::test_oo_optimizable 1237s 1.93s call tests/test_downstream.py::test_oo_optimized_datetime_index_unpickle 1237s 0.13s call tests/test_downstream.py::test_dask 1237s 0.02s call tests/test_downstream.py::test_construct_dask_float_array_int_dtype_match_ndarray 1237s 0.01s call tests/test_downstream.py::test_yaml_dump 1237s 0.01s call tests/test_downstream.py::test_dask_ufunc 1237s 0.01s call tests/test_downstream.py::test_frame_setitem_dask_array_into_new_col 1237s 1237s (23 durations < 0.005s hidden. Use -vv to show these durations.) 1237s ============= 17 passed, 8 skipped, 1 xfailed, 3 warnings in 5.13s ============= 1237s + echo 'rdjoqkol test state = true' 1237s + for TEST_SUBSET in $modpath/tests/* 1237s rdjoqkol test state = true 1237s + echo /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 1237s + grep -q -e __pycache__ 1237s + PANDAS_CI=1 1237s + LC_ALL=C.UTF-8 1237s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 1238s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1238s 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" 1238s 1238s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1238s ============================= test session starts ============================== 1238s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1238s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1238s rootdir: /usr/lib/python3/dist-packages/pandas 1238s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1238s 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 1238s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1238s collected 36 items 1238s 1238s ../../../usr/lib/python3/dist-packages/pandas/tests/test_errors.py .................................... 1238s 1238s =============================== warnings summary =============================== 1238s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1238s /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-056dbyhv' 1238s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1238s 1238s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1238s /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-wxycxkqg' 1238s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1238s 1238s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1238s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1238s ============================= slowest 30 durations ============================= 1238s 1238s (30 durations < 0.005s hidden. Use -vv to show these durations.) 1238s ======================== 36 passed, 2 warnings in 0.17s ======================== 1238s rdjoqkol test state = true 1238s + echo 'rdjoqkol test state = true' 1238s + for TEST_SUBSET in $modpath/tests/* 1238s + echo /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 1238s + grep -q -e __pycache__ 1238s + PANDAS_CI=1 1238s + LC_ALL=C.UTF-8 1238s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 1239s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1239s 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" 1239s 1239s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1239s ============================= test session starts ============================== 1239s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1239s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1239s rootdir: /usr/lib/python3/dist-packages/pandas 1239s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1239s 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 1239s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1239s collected 243 items 1239s 1241s ../../../usr/lib/python3/dist-packages/pandas/tests/test_expressions.py ................................................................................................................................................................................................................................................... 1241s 1241s =============================== warnings summary =============================== 1241s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1241s /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-9bln6k9w' 1241s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1241s 1241s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1241s /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-3wttz0mx' 1241s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1241s 1241s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1241s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1241s ============================= slowest 30 durations ============================= 1241s 0.02s call tests/test_expressions.py::TestExpressions::test_invalid 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ne-False-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[eq-True-_integer] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[le-False-_integer] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[add-True-_integer] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[le-False-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[le-True-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_integer_integers] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[lt-False-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[gt-False-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ge-False-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[lt-True-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[sub-True-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[sub-False-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ge-True-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[gt-True-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[le-False-_integer_integers] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-True-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_frame] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[add-False-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ne-True-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-False-_integer_integers] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[eq-True-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[add-True-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ne-False-_mixed2] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[truediv-False-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-False-_mixed] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_where[_mixed-True] 1241s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mul-False-_mixed] 1241s ======================= 243 passed, 2 warnings in 1.61s ======================== 1241s + echo 'rdjoqkol test state = true' 1241s + for TEST_SUBSET in $modpath/tests/* 1241s + echo /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 1241s + grep -q -e __pycache__ 1241s rdjoqkol test state = true 1241s + PANDAS_CI=1 1241s + LC_ALL=C.UTF-8 1241s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 1242s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1242s 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" 1242s 1242s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1242s ============================= test session starts ============================== 1242s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1242s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1242s rootdir: /usr/lib/python3/dist-packages/pandas 1242s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1242s 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 1242s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1242s collected 5 items 1242s 1242s ../../../usr/lib/python3/dist-packages/pandas/tests/test_flags.py ..... 1242s 1242s =============================== warnings summary =============================== 1242s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1242s /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-dzquiejk' 1242s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1242s 1242s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1242s /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-d8ux33qh' 1242s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1242s 1242s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1242s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1242s ============================= slowest 30 durations ============================= 1242s 1242s (15 durations < 0.005s hidden. Use -vv to show these durations.) 1242s ======================== 5 passed, 2 warnings in 0.14s ========================= 1242s + echo 'rdjoqkol test state = true' 1242s + for TEST_SUBSET in $modpath/tests/* 1242s + echo /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 1242s + grep -q -e __pycache__ 1242s rdjoqkol test state = true 1242s + PANDAS_CI=1 1242s + LC_ALL=C.UTF-8 1242s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 1243s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1243s 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" 1243s 1243s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1243s ============================= test session starts ============================== 1243s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1243s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1243s rootdir: /usr/lib/python3/dist-packages/pandas 1243s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1243s 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 1243s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1243s collected 19 items 1243s 1244s ../../../usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py ................... 1244s 1244s =============================== warnings summary =============================== 1244s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1244s /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-exgyp2q4' 1244s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1244s 1244s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1244s /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-agfeamse' 1244s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1244s 1244s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1244s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1244s ============================= slowest 30 durations ============================= 1244s 0.02s call tests/test_multilevel.py::TestMultiLevel::test_reindex_level 1244s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_alignment 1244s 0.01s setup tests/test_multilevel.py::TestMultiLevel::test_reindex_level 1244s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_level_with_tuples 1244s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_groupby_multilevel 1244s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_reindex_level_partial_selection 1244s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_groupby_transform 1244s 0.01s setup tests/test_multilevel.py::TestMultiLevel::test_reindex_preserve_levels 1244s 0.01s setup tests/test_multilevel.py::TestMultiLevel::test_groupby_multilevel 1244s 1244s (21 durations < 0.005s hidden. Use -vv to show these durations.) 1244s ======================== 19 passed, 2 warnings in 0.36s ======================== 1244s + echo 'rdjoqkol test state = true' 1244s + for TEST_SUBSET in $modpath/tests/* 1244s rdjoqkol test state = true 1244s + echo /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 1244s + grep -q -e __pycache__ 1244s + PANDAS_CI=1 1244s + LC_ALL=C.UTF-8 1244s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 1245s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1245s 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" 1245s 1245s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1245s ============================= test session starts ============================== 1245s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1245s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1245s rootdir: /usr/lib/python3/dist-packages/pandas 1245s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1245s 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 1245s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1245s collected 245 items 1245s 1246s ../../../usr/lib/python3/dist-packages/pandas/tests/test_nanops.py ..................................................................................................................................................................................................................................................... 1246s 1246s =============================== warnings summary =============================== 1246s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1246s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-u7_f8rud' 1246s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1246s 1246s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1246s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-7ovswoh8' 1246s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1246s 1246s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1246s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1246s ============================= slowest 30 durations ============================= 1246s 0.40s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-0] 1246s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-2] 1246s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[True] 1246s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[True] 1246s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-1] 1246s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[False] 1246s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[False] 1246s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-0] 1246s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[True] 1246s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nancorr_spearman 1246s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-1] 1246s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-2] 1246s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[False] 1246s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-2] 1246s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-0] 1246s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-1] 1246s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanvar[True-2] 1246s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanvar[True-1] 1246s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanops_with_warnings[True-reduction-min] 1246s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanvar[True-0] 1246s 1246s (10 durations < 0.005s hidden. Use -vv to show these durations.) 1246s ======================= 245 passed, 2 warnings in 1.42s ======================== 1246s rdjoqkol test state = true 1246s + echo 'rdjoqkol test state = true' 1246s + for TEST_SUBSET in $modpath/tests/* 1246s + echo /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 1246s + grep -q -e __pycache__ 1246s + PANDAS_CI=1 1246s + LC_ALL=C.UTF-8 1246s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 1247s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1247s 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" 1247s 1247s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1247s ============================= test session starts ============================== 1247s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1247s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1247s rootdir: /usr/lib/python3/dist-packages/pandas 1247s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1247s 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 1247s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1247s collected 5 items 1247s 1247s ../../../usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py ..... 1247s 1247s =============================== warnings summary =============================== 1247s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1247s /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-0mqp2_zx' 1247s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1247s 1247s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1247s /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-t9jt2_d3' 1247s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1247s 1247s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1247s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1247s ============================= slowest 30 durations ============================= 1247s 0.01s call tests/test_optional_dependency.py::test_xlrd_version_fallback 1247s 1247s (14 durations < 0.005s hidden. Use -vv to show these durations.) 1247s ======================== 5 passed, 2 warnings in 0.14s ========================= 1247s rdjoqkol test state = true 1247s + echo 'rdjoqkol test state = true' 1247s + for TEST_SUBSET in $modpath/tests/* 1247s + echo /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 1247s + grep -q -e __pycache__ 1247s + PANDAS_CI=1 1247s + LC_ALL=C.UTF-8 1247s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 1248s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1248s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1248s 1248s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1248s ============================= test session starts ============================== 1248s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1248s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1248s rootdir: /usr/lib/python3/dist-packages/pandas 1248s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1248s 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 1248s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1248s collected 7 items 1248s 1249s ../../../usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py ....... 1249s 1249s =============================== warnings summary =============================== 1249s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1249s /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-zvd6rjc7' 1249s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1249s 1249s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1249s /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-xp7wx7en' 1249s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1249s 1249s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1249s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1249s ============================= slowest 30 durations ============================= 1249s 1249s (21 durations < 0.005s hidden. Use -vv to show these durations.) 1249s ======================== 7 passed, 2 warnings in 0.13s ========================= 1249s + echo 'rdjoqkol test state = true' 1249s rdjoqkol test state = true 1249s + for TEST_SUBSET in $modpath/tests/* 1249s + echo /usr/lib/python3/dist-packages/pandas/tests/test_sorting.py 1249s + grep -q -e __pycache__ 1249s + PANDAS_CI=1 1249s + LC_ALL=C.UTF-8 1249s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_sorting.py 1249s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1249s 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" 1249s 1249s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1250s ============================= test session starts ============================== 1250s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1250s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1250s rootdir: /usr/lib/python3/dist-packages/pandas 1250s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1250s 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 1250s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1250s collected 54 items / 15 deselected / 39 selected 1250s 1251s ../../../usr/lib/python3/dist-packages/pandas/tests/test_sorting.py ....................................... 1251s 1251s =============================== warnings summary =============================== 1251s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1251s /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-lv3z8gqb' 1251s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1251s 1251s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1251s /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-5nkr1d2z' 1251s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1251s 1251s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1251s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1251s ============================= slowest 30 durations ============================= 1251s 0.66s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_range 1251s 0.28s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[mean] 1251s 0.27s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[median] 1251s 0.01s call tests/test_sorting.py::TestMerge::test_int64_overflow_outer_merge 1251s 1251s (26 durations < 0.005s hidden. Use -vv to show these durations.) 1251s ================ 39 passed, 15 deselected, 2 warnings in 1.45s ================= 1251s rdjoqkol test state = true 1251s + echo 'rdjoqkol test state = true' 1251s + for TEST_SUBSET in $modpath/tests/* 1251s + echo /usr/lib/python3/dist-packages/pandas/tests/test_take.py 1251s + grep -q -e __pycache__ 1251s + PANDAS_CI=1 1251s + LC_ALL=C.UTF-8 1251s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_take.py 1252s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1252s 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" 1252s 1252s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1252s ============================= test session starts ============================== 1252s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1252s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1252s rootdir: /usr/lib/python3/dist-packages/pandas 1252s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1252s 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 1252s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1252s collected 81 items 1252s 1252s ../../../usr/lib/python3/dist-packages/pandas/tests/test_take.py ................................................................................. 1253s 1253s =============================== warnings summary =============================== 1253s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1253s /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-1h_49307' 1253s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1253s 1253s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1253s /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-w890rsne' 1253s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1253s 1253s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1253s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1253s ============================= slowest 30 durations ============================= 1253s 1253s (30 durations < 0.005s hidden. Use -vv to show these durations.) 1253s ======================== 81 passed, 2 warnings in 0.28s ======================== 1253s rdjoqkol test state = true 1253s + echo 'rdjoqkol test state = true' 1253s + for TEST_SUBSET in $modpath/tests/* 1253s + echo /usr/lib/python3/dist-packages/pandas/tests/tools 1253s + grep -q -e __pycache__ 1253s + PANDAS_CI=1 1253s + LC_ALL=C.UTF-8 1253s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tools 1253s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1253s 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" 1253s 1253s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1254s ============================= test session starts ============================== 1254s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1254s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1254s rootdir: /usr/lib/python3/dist-packages/pandas 1254s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1254s 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 1254s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1254s collected 1510 items 1254s 1258s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss....................................................................ss................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 1258s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_numeric.py ...s.s....................................................................................................................................................................................................................................................xx.......................................................................................................................ssssss.s.s.................................sss...sss.s....ssss.s.s 1258s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_time.py ........... 1258s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_timedelta.py ........................................................................ssssssssssss 1258s 1258s =============================== warnings summary =============================== 1258s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1258s /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-2d5q9zm0' 1258s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1258s 1258s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1258s /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-6yrfxc3j' 1258s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1258s 1258s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1258s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1258s ============================= slowest 30 durations ============================= 1258s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-None] 1258s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-True] 1258s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-True] 1258s 0.08s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-None] 1258s 0.07s 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] 1258s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-True] 1258s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-True] 1258s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-True] 1258s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-None] 1258s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-None] 1258s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-None] 1258s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-None] 1258s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-True] 1258s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-True] 1258s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-None] 1258s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-True] 1258s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-None] 1258s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-None] 1258s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-True] 1258s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-True] 1258s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-True] 1258s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-None] 1258s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-None] 1258s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-None] 1258s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-True] 1258s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_fixed_offset 1258s 0.01s call tests/tools/test_to_datetime.py::TestToDatetimeMisc::test_to_datetime_timezone_name 1258s 0.01s teardown tests/tools/test_to_timedelta.py::test_from_timedelta_arrow_dtype[ms] 1258s 0.01s call tests/tools/test_to_datetime.py::TestToDatetimeDataFrame::test_dataframe[True] 1258s 0.01s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_array_of_dt64s[True-s] 1258s =========== 1451 passed, 55 skipped, 4 xfailed, 2 warnings in 4.92s ============ 1259s + echo 'rdjoqkol test state = true' 1259s + for TEST_SUBSET in $modpath/tests/* 1259s + echo /usr/lib/python3/dist-packages/pandas/tests/tseries 1259s + grep -q -e __pycache__ 1259s rdjoqkol test state = true 1259s + PANDAS_CI=1 1259s + LC_ALL=C.UTF-8 1259s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tseries 1259s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1259s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1259s 1259s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1261s ============================= test session starts ============================== 1261s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1261s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1261s rootdir: /usr/lib/python3/dist-packages/pandas 1261s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1261s 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 1261s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1261s collected 5480 items 1261s 1261s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_freq_code.py ................... 1261s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_frequencies.py .......... 1263s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_inference.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1263s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_calendar.py ........ 1263s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_federal.py ... 1263s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_holiday.py ................................................. 1263s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_observance.py ................................. 1263s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_day.py ....................... 1264s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_hour.py .............................................................................................. 1264s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_month.py ..................... 1264s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_quarter.py .............................................. 1264s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_year.py ................... 1265s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_common.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1265s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_day.py ....... 1265s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_hour.py ............................ 1265s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_month.py .................................................... 1265s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_dst.py .......................... 1265s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_easter.py .......... 1265s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_fiscal.py ............................................................................................................................................. 1266s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_index.py ........................ 1266s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_month.py ............................................................ 1271s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..................................................................................................................................................................................................................................................x................................................................................................................................................................................................................................................ 1272s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets_properties.py .. 1272s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_quarter.py ........................................................................................ 1275s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_ticks.py ............................................................................................................ 1275s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_week.py .............................................. 1275s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_year.py ................................. 1275s 1275s =============================== warnings summary =============================== 1275s tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 1275s /usr/lib/python3/dist-packages/dateutil/zoneinfo/__init__.py:26: UserWarning: I/O error(2): No such file or directory 1275s warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror)) 1275s 1275s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1275s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-vniwpkiw' 1275s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1275s 1275s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1275s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-c3o_lge5' 1275s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1275s 1275s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1275s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1275s ============================= slowest 30 durations ============================= 1275s 0.54s call tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 1275s 0.35s call tests/tseries/offsets/test_offsets_properties.py::test_shift_across_dst 1275s 0.27s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Minute] 1275s 0.22s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Minute] 1275s 0.22s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Micro] 1275s 0.22s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Second] 1275s 0.22s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Hour] 1275s 0.22s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Nano] 1275s 0.20s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Milli] 1275s 0.12s call tests/tseries/offsets/test_custom_business_day.py::TestCustomBusinessDay::test_calendar 1275s 0.11s call tests/tseries/offsets/test_custom_business_hour.py::TestCustomBusinessHour::test_us_federal_holiday_with_datetime 1275s 0.10s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Hour] 1275s 0.09s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Micro] 1275s 0.09s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Second] 1275s 0.09s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Milli] 1275s 0.09s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Nano] 1275s 0.08s call tests/tseries/offsets/test_common.py::test_apply_out_of_range[tzlocal()-YearEnd] 1275s 0.03s teardown tests/tseries/offsets/test_year.py::test_add_out_of_pydatetime_range 1275s 0.03s call tests/tseries/offsets/test_offsets.py::TestCommon::test_rollback[FY5253Quarter] 1275s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[BYearBegin--2] 1275s 0.03s call tests/tseries/offsets/test_business_month.py::test_apply_index[BusinessMonthBegin--2] 1275s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[BusinessMonthBegin--2] 1275s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterEnd--2] 1275s 0.03s call tests/tseries/offsets/test_offsets.py::TestCommon::test_rollback[CustomBusinessMonthBegin1] 1275s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[BYearEnd--2] 1275s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterBegin--2] 1275s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[YearEnd--2] 1275s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[QuarterBegin--2] 1275s 0.03s call tests/tseries/offsets/test_offsets.py::TestCommon::test_rollback[CustomBusinessMonthBegin0] 1275s 0.02s call tests/tseries/offsets/test_business_month.py::test_apply_index[BusinessMonthEnd-1] 1275s ================= 5478 passed, 2 xfailed, 3 warnings in 15.36s ================= 1276s + echo 'rdjoqkol test state = true' 1276s + for TEST_SUBSET in $modpath/tests/* 1276s + echo /usr/lib/python3/dist-packages/pandas/tests/tslibs 1276s rdjoqkol test state = true 1276s + grep -q -e __pycache__ 1276s + PANDAS_CI=1 1276s + LC_ALL=C.UTF-8 1276s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tslibs 1276s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1276s 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" 1276s 1276s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1277s ============================= test session starts ============================== 1277s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1277s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1277s rootdir: /usr/lib/python3/dist-packages/pandas 1277s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1277s 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 1277s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1277s collected 1140 items 1277s 1277s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_api.py . 1277s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_array_to_datetime.py ............................................ 1277s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_ccalendar.py ................. 1280s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_conversion.py ...................................................................... 1280s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_fields.py .... 1280s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_libfrequencies.py ............ 1280s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_liboffsets.py .......................................................................... 1280s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_np_datetime.py ........ 1280s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_npy_units.py .. 1280s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parse_iso8601.py ................................................... 1287s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parsing.py .............................................................................................................................................x...x................................. 1287s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_period.py ....................................... 1287s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_resolution.py ................... 1287s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_strptime.py ....... 1287s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timedeltas.py ......................... 1288s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timezones.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1288s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_to_offset.py ................................................................................................... 1288s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_tzconversion.py . 1288s 1288s =============================== warnings summary =============================== 1288s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1288s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-dkb2kn1i' 1288s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1288s 1288s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1288s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-7shd55it' 1288s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1288s 1288s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1288s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1288s ============================= slowest 30 durations ============================= 1288s 0.38s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-True-.] 1288s 0.33s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-False-.] 1288s 0.28s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['dateutil/Asia/Singapore'] 1288s 0.26s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[datetime.timezone(datetime.timedelta(seconds=3600))] 1288s 0.23s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[tzlocal()] 1288s 0.22s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[datetime.timezone(datetime.timedelta(days=-1, seconds=82800), 'foo')] 1288s 0.22s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(-300)] 1288s 0.20s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['+01:15'] 1288s 0.19s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC-02:15'] 1288s 0.19s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC+01:15'] 1288s 0.18s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['-02:15'] 1288s 0.18s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True--] 1288s 0.17s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(300)] 1288s 0.15s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['Asia/Tokyo'] 1288s 0.14s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %d %Y-False- ] 1288s 0.13s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-False--] 1288s 0.13s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True- ] 1288s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False-.] 1288s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False-/] 1288s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False--] 1288s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-False-/] 1288s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True-/] 1288s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False- ] 1288s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True--] 1288s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False-/] 1288s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True- ] 1288s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y%m%d-False-.] 1288s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-True-.] 1288s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-True- ] 1288s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True-.] 1288s ================= 1138 passed, 2 xfailed, 2 warnings in 11.72s ================= 1288s + echo 'rdjoqkol test state = true' 1288s + for TEST_SUBSET in $modpath/tests/* 1288s + echo /usr/lib/python3/dist-packages/pandas/tests/util 1288s + grep -q -e __pycache__ 1288s + PANDAS_CI=1 1288s + LC_ALL=C.UTF-8 1288s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/util 1288s rdjoqkol test state = true 1289s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1289s 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" 1289s 1289s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1290s ============================= test session starts ============================== 1290s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1290s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1290s rootdir: /usr/lib/python3/dist-packages/pandas 1290s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1290s 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 1290s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1290s collected 916 items 1290s 1290s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_almost_equal.py .................................................................................................................................................................... 1290s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_attr_equal.py .......................................... 1290s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_categorical_equal.py .......... 1290s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_extension_array_equal.py ..................... 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_frame_equal.py ............................................................................................................... 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_index_equal.py ................................................................ 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_interval_array_equal.py ....... 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_numpy_array_equal.py ......................... 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_produces_warning.py ............................................................................................................................ 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_series_equal.py .............................................................................................. 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate.py ... 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_kwarg.py .............. 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_nonkeyword_arguments.py ................... 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_doc.py .... 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_hashing.py ..................................................................................................................................................... 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_rewrite_warning.py .......... 1291s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_shares_memory.py .s 1292s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_show_versions.py .... 1292s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_util.py ...sx.. 1292s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args.py ...... 1292s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args_and_kwargs.py ...... 1292s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_inclusive.py ........... 1292s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_kwargs.py .................. 1292s 1292s =============================== warnings summary =============================== 1292s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1292s /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-iars_wy0' 1292s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1292s 1292s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1292s /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-_vzg68mh' 1292s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1292s 1292s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1292s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1292s ============================= slowest 30 durations ============================= 1292s 0.64s call tests/util/test_show_versions.py::test_show_versions 1292s 0.02s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-7] 1292s 0.02s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-7] 1292s 0.01s call tests/util/test_show_versions.py::test_show_versions_console_json 1292s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-6] 1292s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-6] 1292s 0.01s call tests/util/test_show_versions.py::test_json_output_match 1292s 0.01s teardown tests/util/test_validate_kwargs.py::test_validate_bool_kwarg[None-copy] 1292s 1292s (22 durations < 0.005s hidden. Use -vv to show these durations.) 1292s ============ 913 passed, 2 skipped, 1 xfailed, 2 warnings in 2.75s ============= 1293s rdjoqkol test state = true 1293s + echo 'rdjoqkol test state = true' 1293s + for TEST_SUBSET in $modpath/tests/* 1293s + echo /usr/lib/python3/dist-packages/pandas/tests/window 1293s + grep -q -e __pycache__ 1293s + PANDAS_CI=1 1293s + LC_ALL=C.UTF-8 1293s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.GEshUB/build.sMK/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/window 1293s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1293s 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" 1293s 1293s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1295s ============================= test session starts ============================== 1295s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1295s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1295s rootdir: /usr/lib/python3/dist-packages/pandas 1295s configfile: ../../../../../tmp/autopkgtest.GEshUB/build.sMK/src/pyproject.toml 1295s 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 1295s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1295s collected 10242 items / 536 deselected / 1 skipped / 9706 selected 1295s 1299s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1300s ../../../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................................................................................................................................................................................................................................................................................ 1302s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1304s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1305s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 1306s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 1306s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 1311s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1312s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 1313s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 1314s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 1315s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1317s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ........................................................................................................................................................................................................................................................................................................................ 1320s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1322s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 1323s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 1323s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 1324s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 1325s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 1325s 1325s =============================== warnings summary =============================== 1325s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1325s /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-wy0ynww2' 1325s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1325s 1325s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1325s /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-sxyi1zbf' 1325s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1325s 1325s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1325s -- generated xml file: /tmp/autopkgtest.GEshUB/autopkgtest_tmp/test-data.xml --- 1325s ============================= slowest 30 durations ============================= 1325s 0.58s call tests/window/test_rolling_functions.py::test_rolling_functions_window_non_shrinkage[14] 1325s 0.19s teardown tests/window/test_numba.py::TestEngine::test_cache_apply[False-True-True-5-True] 1325s 0.17s call tests/window/test_apply.py::test_time_rule_frame[False] 1325s 0.12s call tests/window/test_apply.py::test_frame[False] 1325s 0.07s teardown tests/window/test_win_type.py::test_rolling_center_axis_1 1325s 0.06s call tests/window/test_expanding.py::test_expanding_corr_pairwise 1325s 0.06s call tests/window/test_expanding.py::test_expanding_cov_pairwise 1325s 0.05s call tests/window/test_apply.py::test_center_reindex_frame[False] 1325s 0.04s call tests/window/test_apply.py::test_min_periods[False-None-0] 1325s 0.04s call tests/window/test_apply.py::test_min_periods[False-1-0] 1325s 0.04s call tests/window/test_ewm.py::test_ewm_pairwise_cov_corr[corr] 1325s 0.04s call tests/window/test_apply.py::test_center_reindex_series[False] 1325s 0.03s call tests/window/test_ewm.py::test_ewm_pairwise_cov_corr[cov] 1325s 0.03s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[corr] 1325s 0.03s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[cov] 1325s 0.03s call tests/window/test_pairwise.py::TestPairwise::test_cov_mulittindex 1325s 0.03s call tests/window/test_apply.py::test_nans[False] 1325s 0.03s call tests/window/test_pairwise.py::test_flex_binary_frame[corr] 1325s 0.02s call tests/window/test_pairwise.py::test_flex_binary_frame[cov] 1325s 0.02s call tests/window/test_expanding.py::test_expanding_corr_pairwise_diff_length 1325s 0.02s call tests/window/test_expanding.py::test_expanding_cov_pairwise_diff_length 1325s 0.02s call tests/window/test_apply.py::test_min_periods[False-2-0] 1325s 0.02s call tests/window/test_rolling.py::test_numeric_only_corr_cov_frame[False-False-cov] 1325s 0.02s call tests/window/test_rolling.py::test_numeric_only_corr_cov_frame[False-False-corr] 1325s 0.02s call tests/window/test_apply.py::test_time_rule_series[False] 1325s 0.02s call tests/window/test_rolling.py::test_multi_index_names 1325s 0.02s call tests/window/test_api.py::test_agg[None] 1325s 0.02s call tests/window/test_api.py::test_agg[5] 1325s 0.01s call tests/window/test_api.py::test_agg[1] 1325s 0.01s call tests/window/test_api.py::test_agg[2] 1325s == 9014 passed, 650 skipped, 536 deselected, 43 xfailed, 2 warnings in 31.17s == 1326s + echo 'rdjoqkol test state = true' 1326s + true 1326s rdjoqkol test state = true 1326s autopkgtest [20:22:38]: test unittests3: -----------------------] 1327s autopkgtest [20:22:39]: test unittests3: - - - - - - - - - - results - - - - - - - - - - 1327s unittests3 PASS 1327s autopkgtest [20:22:39]: test ignoredtests: preparing testbed 1327s Reading package lists... 1328s Building dependency tree... 1328s Reading state information... 1328s Starting pkgProblemResolver with broken count: 0 1328s Starting 2 pkgProblemResolver with broken count: 0 1328s Done 1329s The following NEW packages will be installed: 1329s libpq5 python3-psycopg2 python3-pymysql 1329s 0 upgraded, 3 newly installed, 0 to remove and 102 not upgraded. 1329s Need to get 325 kB of archives. 1329s After this operation, 1121 kB of additional disk space will be used. 1329s Get:1 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libpq5 amd64 17.4-2 [143 kB] 1329s Get:2 http://ftpmaster.internal/ubuntu questing/main amd64 python3-psycopg2 amd64 2.9.10-1build1 [142 kB] 1329s Get:3 http://ftpmaster.internal/ubuntu questing/main amd64 python3-pymysql all 1.1.1-2ubuntu1 [39.5 kB] 1330s Fetched 325 kB in 1s (566 kB/s) 1330s Selecting previously unselected package libpq5:amd64. 1330s (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 ... 104450 files and directories currently installed.) 1330s Preparing to unpack .../libpq5_17.4-2_amd64.deb ... 1330s Unpacking libpq5:amd64 (17.4-2) ... 1330s Selecting previously unselected package python3-psycopg2. 1330s Preparing to unpack .../python3-psycopg2_2.9.10-1build1_amd64.deb ... 1330s Unpacking python3-psycopg2 (2.9.10-1build1) ... 1330s Selecting previously unselected package python3-pymysql. 1330s Preparing to unpack .../python3-pymysql_1.1.1-2ubuntu1_all.deb ... 1330s Unpacking python3-pymysql (1.1.1-2ubuntu1) ... 1330s Setting up libpq5:amd64 (17.4-2) ... 1330s Setting up python3-psycopg2 (2.9.10-1build1) ... 1330s Setting up python3-pymysql (1.1.1-2ubuntu1) ... 1330s Processing triggers for libc-bin (2.41-6ubuntu1) ... 1331s autopkgtest [20:22:43]: testbed environment configured for cross-architecture building 1331s autopkgtest [20:22:43]: test ignoredtests: [----------------------- 1332s === python3.13 === 1332s 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 1333s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1333s 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" 1333s 1333s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1335s ============================= test session starts ============================== 1335s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1335s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1335s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1335s 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 1335s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1335s collected 10446 items / 536 deselected / 2 skipped / 9910 selected 1335s 1338s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 1339s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py ..............................s 1341s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1343s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1343s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 1376s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1387s ../../../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................................................................................................................................................................................................................................................................................ 1411s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1436s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1439s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 1446s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 1450s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 1524s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1533s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 1543s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 1547s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 1559s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1572s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ........................................................................................................................................................................................................................................................................................................................ 1599s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1614s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 1620s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 1628s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 1631s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 1761s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 1761s 1761s =============================== warnings summary =============================== 1761s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_numba.py:11 1761s /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 1761s pytestmark = pytest.mark.single_cpu 1761s 1761s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py:944 1761s /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 1761s @pytest.mark.single_cpu 1761s 1761s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py:14 1761s /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 1761s pytestmark = pytest.mark.single_cpu 1761s 1761s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:22 1761s /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 1761s pytestmark = pytest.mark.single_cpu 1761s 1761s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:230 1761s /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 1761s @pytest.mark.single_cpu 1761s 1761s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:21 1761s /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 1761s pytestmark = pytest.mark.single_cpu 1761s 1761s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:326 1761s /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 1761s @pytest.mark.slow 1761s 1761s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_online.py:11 1761s /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 1761s pytestmark = pytest.mark.single_cpu 1761s 1761s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py:155 1761s /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 1761s @pytest.mark.slow 1761s 1761s frame/test_ufunc.py: 32 warnings 1761s groupby/test_timegrouper.py: 31 warnings 1761s groupby/transform/test_numba.py: 53 warnings 1761s groupby/aggregate/test_numba.py: 35 warnings 1761s util/test_numba.py: 1 warning 1761s window/moments/test_moments_consistency_ewm.py: 1088 warnings 1761s window/moments/test_moments_consistency_expanding.py: 380 warnings 1761s window/moments/test_moments_consistency_rolling.py: 760 warnings 1761s window/test_api.py: 937 warnings 1761s window/test_apply.py: 82 warnings 1761s window/test_base_indexer.py: 228 warnings 1761s window/test_cython_aggregations.py: 72 warnings 1761s window/test_dtypes.py: 2580 warnings 1761s window/test_ewm.py: 283 warnings 1761s window/test_expanding.py: 333 warnings 1761s window/test_groupby.py: 115 warnings 1761s window/test_numba.py: 51 warnings 1761s window/test_pairwise.py: 312 warnings 1761s window/test_rolling.py: 888 warnings 1761s window/test_rolling_functions.py: 418 warnings 1761s window/test_rolling_quantile.py: 186 warnings 1761s window/test_rolling_skew_kurt.py: 68 warnings 1761s window/test_timeseries_window.py: 83 warnings 1761s window/test_win_type.py: 287 warnings 1761s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=7062) is multi-threaded, use of fork() may lead to deadlocks in the child. 1761s pid = os.fork() 1761s 1761s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1761s /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-oydy3l63' 1761s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1761s 1761s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1761s /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-cxsk3kxq' 1761s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1761s 1761s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1761s = 9064 passed, 793 skipped, 536 deselected, 55 xfailed, 9314 warnings in 427.52s (0:07:07) = 1762s various xfailed tests - see xfail_tests_nonintel_io.patch, ignore_test_1094417_1088988.patch 1762s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1762s 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" 1762s 1762s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1763s ============================= test session starts ============================== 1763s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1763s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1763s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1763s 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 1763s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1763s collected 366 items 1763s 1777s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py ...................................................FFFFFFFFF................................................................................................................................... 1780s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py ....F................ 1786s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py ............................................F..................... 1791s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sF.........s. 1795s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py ..F.............FF..F.sFFFFFF................................. 1795s 1795s =================================== FAILURES =================================== 1795s ___________________________ test_complibs[blosc2-1] ____________________________ 1795s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-52/test_complibs_blosc2_1_0') 1795s lvl = 1, lib = 'blosc2' 1795s request = > 1795s 1795s @pytest.mark.parametrize("lvl", range(10)) 1795s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1795s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1795s @pytest.mark.skipif( 1795s not PY311 and is_ci_environment() and is_platform_linux(), 1795s reason="Segfaulting in a CI environment" 1795s # with xfail, would sometimes raise UnicodeDecodeError 1795s # invalid state byte 1795s ) 1795s def test_complibs(tmp_path, lvl, lib, request): 1795s # GH14478 1795s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1795s request.applymarker( 1795s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1795s ) 1795s df = DataFrame( 1795s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1795s ) 1795s 1795s # Remove lzo if its not available on this platform 1795s if not tables.which_lib_version("lzo"): 1795s pytest.skip("lzo not available") 1795s # Remove bzip2 if its not available on this platform 1795s if not tables.which_lib_version("bzip2"): 1795s pytest.skip("bzip2 not available") 1795s 1795s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1795s gname = f"{lvl}_{lib}" 1795s 1795s # Write and read file to see if data is consistent 1795s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1795s result = read_hdf(tmpfile, gname) 1795s tm.assert_frame_equal(result, df) 1795s 1795s # Open file and check metadata for correct amount of compression 1795s with tables.open_file(tmpfile, mode="r") as h5table: 1795s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1795s assert node.filters.complevel == lvl 1795s if lvl == 0: 1795s assert node.filters.complib is None 1795s else: 1795s > assert node.filters.complib == lib 1795s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1795s E 1795s E - blosc2 1795s E + blosc2:blosclz 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1795s ___________________________ test_complibs[blosc2-2] ____________________________ 1795s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-53/test_complibs_blosc2_2_0') 1795s lvl = 2, lib = 'blosc2' 1795s request = > 1795s 1795s @pytest.mark.parametrize("lvl", range(10)) 1795s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1795s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1795s @pytest.mark.skipif( 1795s not PY311 and is_ci_environment() and is_platform_linux(), 1795s reason="Segfaulting in a CI environment" 1795s # with xfail, would sometimes raise UnicodeDecodeError 1795s # invalid state byte 1795s ) 1795s def test_complibs(tmp_path, lvl, lib, request): 1795s # GH14478 1795s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1795s request.applymarker( 1795s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1795s ) 1795s df = DataFrame( 1795s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1795s ) 1795s 1795s # Remove lzo if its not available on this platform 1795s if not tables.which_lib_version("lzo"): 1795s pytest.skip("lzo not available") 1795s # Remove bzip2 if its not available on this platform 1795s if not tables.which_lib_version("bzip2"): 1795s pytest.skip("bzip2 not available") 1795s 1795s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1795s gname = f"{lvl}_{lib}" 1795s 1795s # Write and read file to see if data is consistent 1795s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1795s result = read_hdf(tmpfile, gname) 1795s tm.assert_frame_equal(result, df) 1795s 1795s # Open file and check metadata for correct amount of compression 1795s with tables.open_file(tmpfile, mode="r") as h5table: 1795s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1795s assert node.filters.complevel == lvl 1795s if lvl == 0: 1795s assert node.filters.complib is None 1795s else: 1795s > assert node.filters.complib == lib 1795s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1795s E 1795s E - blosc2 1795s E + blosc2:blosclz 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1795s ___________________________ test_complibs[blosc2-3] ____________________________ 1795s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-54/test_complibs_blosc2_3_0') 1795s lvl = 3, lib = 'blosc2' 1795s request = > 1795s 1795s @pytest.mark.parametrize("lvl", range(10)) 1795s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1795s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1795s @pytest.mark.skipif( 1795s not PY311 and is_ci_environment() and is_platform_linux(), 1795s reason="Segfaulting in a CI environment" 1795s # with xfail, would sometimes raise UnicodeDecodeError 1795s # invalid state byte 1795s ) 1795s def test_complibs(tmp_path, lvl, lib, request): 1795s # GH14478 1795s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1795s request.applymarker( 1795s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1795s ) 1795s df = DataFrame( 1795s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1795s ) 1795s 1795s # Remove lzo if its not available on this platform 1795s if not tables.which_lib_version("lzo"): 1795s pytest.skip("lzo not available") 1795s # Remove bzip2 if its not available on this platform 1795s if not tables.which_lib_version("bzip2"): 1795s pytest.skip("bzip2 not available") 1795s 1795s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1795s gname = f"{lvl}_{lib}" 1795s 1795s # Write and read file to see if data is consistent 1795s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1795s result = read_hdf(tmpfile, gname) 1795s tm.assert_frame_equal(result, df) 1795s 1795s # Open file and check metadata for correct amount of compression 1795s with tables.open_file(tmpfile, mode="r") as h5table: 1795s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1795s assert node.filters.complevel == lvl 1795s if lvl == 0: 1795s assert node.filters.complib is None 1795s else: 1795s > assert node.filters.complib == lib 1795s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1795s E 1795s E - blosc2 1795s E + blosc2:blosclz 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1795s ___________________________ test_complibs[blosc2-4] ____________________________ 1795s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-55/test_complibs_blosc2_4_0') 1795s lvl = 4, lib = 'blosc2' 1795s request = > 1795s 1795s @pytest.mark.parametrize("lvl", range(10)) 1795s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1795s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1795s @pytest.mark.skipif( 1795s not PY311 and is_ci_environment() and is_platform_linux(), 1795s reason="Segfaulting in a CI environment" 1795s # with xfail, would sometimes raise UnicodeDecodeError 1795s # invalid state byte 1795s ) 1795s def test_complibs(tmp_path, lvl, lib, request): 1795s # GH14478 1795s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1795s request.applymarker( 1795s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1795s ) 1795s df = DataFrame( 1795s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1795s ) 1795s 1795s # Remove lzo if its not available on this platform 1795s if not tables.which_lib_version("lzo"): 1795s pytest.skip("lzo not available") 1795s # Remove bzip2 if its not available on this platform 1795s if not tables.which_lib_version("bzip2"): 1795s pytest.skip("bzip2 not available") 1795s 1795s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1795s gname = f"{lvl}_{lib}" 1795s 1795s # Write and read file to see if data is consistent 1795s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1795s result = read_hdf(tmpfile, gname) 1795s tm.assert_frame_equal(result, df) 1795s 1795s # Open file and check metadata for correct amount of compression 1795s with tables.open_file(tmpfile, mode="r") as h5table: 1795s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1795s assert node.filters.complevel == lvl 1795s if lvl == 0: 1795s assert node.filters.complib is None 1795s else: 1795s > assert node.filters.complib == lib 1795s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1795s E 1795s E - blosc2 1795s E + blosc2:blosclz 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1795s ___________________________ test_complibs[blosc2-5] ____________________________ 1795s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-56/test_complibs_blosc2_5_0') 1795s lvl = 5, lib = 'blosc2' 1795s request = > 1795s 1795s @pytest.mark.parametrize("lvl", range(10)) 1795s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1795s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1795s @pytest.mark.skipif( 1795s not PY311 and is_ci_environment() and is_platform_linux(), 1795s reason="Segfaulting in a CI environment" 1795s # with xfail, would sometimes raise UnicodeDecodeError 1795s # invalid state byte 1795s ) 1795s def test_complibs(tmp_path, lvl, lib, request): 1795s # GH14478 1795s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1795s request.applymarker( 1795s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1795s ) 1795s df = DataFrame( 1795s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1795s ) 1795s 1795s # Remove lzo if its not available on this platform 1795s if not tables.which_lib_version("lzo"): 1795s pytest.skip("lzo not available") 1795s # Remove bzip2 if its not available on this platform 1795s if not tables.which_lib_version("bzip2"): 1795s pytest.skip("bzip2 not available") 1795s 1795s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1795s gname = f"{lvl}_{lib}" 1795s 1795s # Write and read file to see if data is consistent 1795s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1795s result = read_hdf(tmpfile, gname) 1795s tm.assert_frame_equal(result, df) 1795s 1795s # Open file and check metadata for correct amount of compression 1795s with tables.open_file(tmpfile, mode="r") as h5table: 1795s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1795s assert node.filters.complevel == lvl 1795s if lvl == 0: 1795s assert node.filters.complib is None 1795s else: 1795s > assert node.filters.complib == lib 1795s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1795s E 1795s E - blosc2 1795s E + blosc2:blosclz 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1795s ___________________________ test_complibs[blosc2-6] ____________________________ 1795s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-57/test_complibs_blosc2_6_0') 1795s lvl = 6, lib = 'blosc2' 1795s request = > 1795s 1795s @pytest.mark.parametrize("lvl", range(10)) 1795s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1795s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1795s @pytest.mark.skipif( 1795s not PY311 and is_ci_environment() and is_platform_linux(), 1795s reason="Segfaulting in a CI environment" 1795s # with xfail, would sometimes raise UnicodeDecodeError 1795s # invalid state byte 1795s ) 1795s def test_complibs(tmp_path, lvl, lib, request): 1795s # GH14478 1795s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1795s request.applymarker( 1795s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1795s ) 1795s df = DataFrame( 1795s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1795s ) 1795s 1795s # Remove lzo if its not available on this platform 1795s if not tables.which_lib_version("lzo"): 1795s pytest.skip("lzo not available") 1795s # Remove bzip2 if its not available on this platform 1795s if not tables.which_lib_version("bzip2"): 1795s pytest.skip("bzip2 not available") 1795s 1795s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1795s gname = f"{lvl}_{lib}" 1795s 1795s # Write and read file to see if data is consistent 1795s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1795s result = read_hdf(tmpfile, gname) 1795s tm.assert_frame_equal(result, df) 1795s 1795s # Open file and check metadata for correct amount of compression 1795s with tables.open_file(tmpfile, mode="r") as h5table: 1795s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1795s assert node.filters.complevel == lvl 1795s if lvl == 0: 1795s assert node.filters.complib is None 1795s else: 1795s > assert node.filters.complib == lib 1795s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1795s E 1795s E - blosc2 1795s E + blosc2:blosclz 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1795s ___________________________ test_complibs[blosc2-7] ____________________________ 1795s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-58/test_complibs_blosc2_7_0') 1795s lvl = 7, lib = 'blosc2' 1795s request = > 1795s 1795s @pytest.mark.parametrize("lvl", range(10)) 1795s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1795s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1795s @pytest.mark.skipif( 1795s not PY311 and is_ci_environment() and is_platform_linux(), 1795s reason="Segfaulting in a CI environment" 1795s # with xfail, would sometimes raise UnicodeDecodeError 1795s # invalid state byte 1795s ) 1795s def test_complibs(tmp_path, lvl, lib, request): 1795s # GH14478 1795s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1795s request.applymarker( 1795s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1795s ) 1795s df = DataFrame( 1795s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1795s ) 1795s 1795s # Remove lzo if its not available on this platform 1795s if not tables.which_lib_version("lzo"): 1795s pytest.skip("lzo not available") 1795s # Remove bzip2 if its not available on this platform 1795s if not tables.which_lib_version("bzip2"): 1795s pytest.skip("bzip2 not available") 1795s 1795s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1795s gname = f"{lvl}_{lib}" 1795s 1795s # Write and read file to see if data is consistent 1795s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1795s result = read_hdf(tmpfile, gname) 1795s tm.assert_frame_equal(result, df) 1795s 1795s # Open file and check metadata for correct amount of compression 1795s with tables.open_file(tmpfile, mode="r") as h5table: 1795s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1795s assert node.filters.complevel == lvl 1795s if lvl == 0: 1795s assert node.filters.complib is None 1795s else: 1795s > assert node.filters.complib == lib 1795s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1795s E 1795s E - blosc2 1795s E + blosc2:blosclz 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1795s ___________________________ test_complibs[blosc2-8] ____________________________ 1795s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-59/test_complibs_blosc2_8_0') 1795s lvl = 8, lib = 'blosc2' 1795s request = > 1795s 1795s @pytest.mark.parametrize("lvl", range(10)) 1795s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1795s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1795s @pytest.mark.skipif( 1795s not PY311 and is_ci_environment() and is_platform_linux(), 1795s reason="Segfaulting in a CI environment" 1795s # with xfail, would sometimes raise UnicodeDecodeError 1795s # invalid state byte 1795s ) 1795s def test_complibs(tmp_path, lvl, lib, request): 1795s # GH14478 1795s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1795s request.applymarker( 1795s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1795s ) 1795s df = DataFrame( 1795s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1795s ) 1795s 1795s # Remove lzo if its not available on this platform 1795s if not tables.which_lib_version("lzo"): 1795s pytest.skip("lzo not available") 1795s # Remove bzip2 if its not available on this platform 1795s if not tables.which_lib_version("bzip2"): 1795s pytest.skip("bzip2 not available") 1795s 1795s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1795s gname = f"{lvl}_{lib}" 1795s 1795s # Write and read file to see if data is consistent 1795s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1795s result = read_hdf(tmpfile, gname) 1795s tm.assert_frame_equal(result, df) 1795s 1795s # Open file and check metadata for correct amount of compression 1795s with tables.open_file(tmpfile, mode="r") as h5table: 1795s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1795s assert node.filters.complevel == lvl 1795s if lvl == 0: 1795s assert node.filters.complib is None 1795s else: 1795s > assert node.filters.complib == lib 1795s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1795s E 1795s E - blosc2 1795s E + blosc2:blosclz 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1795s ___________________________ test_complibs[blosc2-9] ____________________________ 1795s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-60/test_complibs_blosc2_9_0') 1795s lvl = 9, lib = 'blosc2' 1795s request = > 1795s 1795s @pytest.mark.parametrize("lvl", range(10)) 1795s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1795s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1795s @pytest.mark.skipif( 1795s not PY311 and is_ci_environment() and is_platform_linux(), 1795s reason="Segfaulting in a CI environment" 1795s # with xfail, would sometimes raise UnicodeDecodeError 1795s # invalid state byte 1795s ) 1795s def test_complibs(tmp_path, lvl, lib, request): 1795s # GH14478 1795s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1795s request.applymarker( 1795s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1795s ) 1795s df = DataFrame( 1795s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1795s ) 1795s 1795s # Remove lzo if its not available on this platform 1795s if not tables.which_lib_version("lzo"): 1795s pytest.skip("lzo not available") 1795s # Remove bzip2 if its not available on this platform 1795s if not tables.which_lib_version("bzip2"): 1795s pytest.skip("bzip2 not available") 1795s 1795s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1795s gname = f"{lvl}_{lib}" 1795s 1795s # Write and read file to see if data is consistent 1795s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1795s result = read_hdf(tmpfile, gname) 1795s tm.assert_frame_equal(result, df) 1795s 1795s # Open file and check metadata for correct amount of compression 1795s with tables.open_file(tmpfile, mode="r") as h5table: 1795s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1795s assert node.filters.complevel == lvl 1795s if lvl == 0: 1795s assert node.filters.complib is None 1795s else: 1795s > assert node.filters.complib == lib 1795s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1795s E 1795s E - blosc2 1795s E + blosc2:blosclz 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1795s ______________________ test_append_frame_column_oriented _______________________ 1795s self = 1795s node = , kwargs = {'side': 'right'} 1795s value = 1795s slobj = slice(0, 4, None) 1795s 1795s def visit_Subscript(self, node, **kwargs) -> ops.Term: 1795s # only allow simple subscripts 1795s 1795s value = self.visit(node.value) 1795s slobj = self.visit(node.slice) 1795s try: 1795s value = value.value 1795s except AttributeError: 1795s pass 1795s 1795s if isinstance(slobj, Term): 1795s # In py39 np.ndarray lookups with Term containing int raise 1795s slobj = slobj.value 1795s 1795s try: 1795s > return self.const_type(value[slobj], self.env) 1795s E TypeError: 'builtin_function_or_method' object is not subscriptable 1795s 1795s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:468: TypeError 1795s 1795s The above exception was the direct cause of the following exception: 1795s 1795s setup_path = 'tmp.__a7c52594-7319-4d55-9ca3-856e143b91b0__.h5' 1795s 1795s @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) 1795s def test_append_frame_column_oriented(setup_path): 1795s with ensure_clean_store(setup_path) as store: 1795s # column oriented 1795s df = DataFrame( 1795s np.random.default_rng(2).standard_normal((10, 4)), 1795s columns=Index(list("ABCD"), dtype=object), 1795s index=date_range("2000-01-01", periods=10, freq="B"), 1795s ) 1795s df.index = df.index._with_freq(None) # freq doesn't round-trip 1795s 1795s _maybe_remove(store, "df1") 1795s store.append("df1", df.iloc[:, :2], axes=["columns"]) 1795s store.append("df1", df.iloc[:, 2:]) 1795s tm.assert_frame_equal(store["df1"], df) 1795s 1795s result = store.select("df1", "columns=A") 1795s expected = df.reindex(columns=["A"]) 1795s tm.assert_frame_equal(expected, result) 1795s 1795s # selection on the non-indexable 1795s > result = store.select("df1", ("columns=A", "index=df.index[0:4]")) 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:311: 1795s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:915: in select 1795s return it.get_result() 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:2038: in get_result 1795s results = self.func(self.start, self.stop, where) 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:899: in func 1795s return s.read(start=_start, stop=_stop, where=_where, columns=columns) 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:4640: in read 1795s result = self._read_axes(where=where, start=start, stop=stop) 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:3826: in _read_axes 1795s selection = Selection(self, where=where, start=start, stop=stop) 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5367: in __init__ 1795s self.terms = self.generate(where) 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5380: in generate 1795s return PyTablesExpr(where, queryables=q, encoding=self.table.encoding) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:610: in __init__ 1795s self.terms = self.parse() 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:824: in parse 1795s return self._visitor.visit(self.expr) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1795s return visitor(node, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:417: in visit_Module 1795s return self.visit(expr, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1795s return visitor(node, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:420: in visit_Expr 1795s return self.visit(node.value, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1795s return visitor(node, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:742: in visit_BoolOp 1795s return reduce(visitor, operands) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:736: in visitor 1795s rhs = self._try_visit_binop(y) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:731: in _try_visit_binop 1795s return self.visit(bop) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1795s return visitor(node, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:715: in visit_Compare 1795s return self.visit(binop) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1795s return visitor(node, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:531: in visit_BinOp 1795s op, op_class, left, right = self._maybe_transform_eq_ne(node) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:453: in _maybe_transform_eq_ne 1795s right = self.visit(node.right, side="right") 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1795s return visitor(node, **kwargs) 1795s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1795s 1795s self = 1795s node = , kwargs = {'side': 'right'} 1795s value = 1795s slobj = slice(0, 4, None) 1795s 1795s def visit_Subscript(self, node, **kwargs) -> ops.Term: 1795s # only allow simple subscripts 1795s 1795s value = self.visit(node.value) 1795s slobj = self.visit(node.slice) 1795s try: 1795s value = value.value 1795s except AttributeError: 1795s pass 1795s 1795s if isinstance(slobj, Term): 1795s # In py39 np.ndarray lookups with Term containing int raise 1795s slobj = slobj.value 1795s 1795s try: 1795s return self.const_type(value[slobj], self.env) 1795s except TypeError as err: 1795s > raise ValueError( 1795s f"cannot subscript {repr(value)} with {repr(slobj)}" 1795s ) from err 1795s E ValueError: cannot subscript with slice(0, 4, None) 1795s 1795s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:470: ValueError 1795s __________________________ test_select_filter_corner ___________________________ 1795s setup_path = 'tmp.__6d74c1bb-e3a8-47ff-84cd-7ed108aef153__.h5' 1795s 1795s @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) 1795s def test_select_filter_corner(setup_path): 1795s df = DataFrame(np.random.default_rng(2).standard_normal((50, 100))) 1795s df.index = [f"{c:3d}" for c in df.index] 1795s df.columns = [f"{c:3d}" for c in df.columns] 1795s 1795s with ensure_clean_store(setup_path) as store: 1795s store.put("frame", df, format="table") 1795s 1795s crit = "columns=df.columns[:75]" 1795s > result = store.select("frame", [crit]) 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:899: 1795s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:915: in select 1795s return it.get_result() 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:2038: in get_result 1795s results = self.func(self.start, self.stop, where) 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:899: in func 1795s return s.read(start=_start, stop=_stop, where=_where, columns=columns) 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:4640: in read 1795s result = self._read_axes(where=where, start=start, stop=stop) 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:3826: in _read_axes 1795s selection = Selection(self, where=where, start=start, stop=stop) 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5367: in __init__ 1795s self.terms = self.generate(where) 1795s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5380: in generate 1795s return PyTablesExpr(where, queryables=q, encoding=self.table.encoding) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:610: in __init__ 1795s self.terms = self.parse() 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:824: in parse 1795s return self._visitor.visit(self.expr) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1795s return visitor(node, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:417: in visit_Module 1795s return self.visit(expr, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1795s return visitor(node, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:420: in visit_Expr 1795s return self.visit(node.value, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1795s return visitor(node, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:715: in visit_Compare 1795s return self.visit(binop) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1795s return visitor(node, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:531: in visit_BinOp 1795s op, op_class, left, right = self._maybe_transform_eq_ne(node) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:453: in _maybe_transform_eq_ne 1795s right = self.visit(node.right, side="right") 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1795s return visitor(node, **kwargs) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:456: in visit_Subscript 1795s value = self.visit(node.value) 1795s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1795s return visitor(node, **kwargs) 1795s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1795s 1795s self = 1795s node = , kwargs = {}, attr = 'columns' 1795s value = , ctx = 1795s resolved = 'df' 1795s 1795s def visit_Attribute(self, node, **kwargs): 1795s attr = node.attr 1795s value = node.value 1795s 1795s ctx = type(node.ctx) 1795s if ctx == ast.Load: 1795s # resolve the value 1795s resolved = self.visit(value) 1795s 1795s # try to get the value to see if we are another expression 1795s try: 1795s resolved = resolved.value 1795s except AttributeError: 1795s pass 1795s 1795s try: 1795s return self.term_type(getattr(resolved, attr), self.env) 1795s except AttributeError: 1795s # something like datetime.datetime where scope is overridden 1795s if isinstance(value, ast.Name) and value.id == attr: 1795s return resolved 1795s 1795s > raise ValueError(f"Invalid Attribute context {ctx.__name__}") 1795s E ValueError: Invalid Attribute context Load 1795s 1795s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:496: ValueError 1795s __________________ test_frame_setitem_dask_array_into_new_col __________________ 1795s @pytest.mark.xfail( 1795s condition=True,#not IS64, 1795s reason="ignoring https://bugs.debian.org/1094417 to unblock transition",#"dask has different nativesize-int vs int64 type rules", 1795s strict=False, 1795s ) 1795s def test_frame_setitem_dask_array_into_new_col(): 1795s # GH#47128 1795s 1795s # dask sets "compute.use_numexpr" to False, so catch the current value 1795s # and ensure to reset it afterwards to avoid impacting other tests 1795s olduse = pd.get_option("compute.use_numexpr") 1795s 1795s try: 1795s da = td.versioned_importorskip("dask.array") 1795s 1795s dda = da.array([1, 2]) 1795s df = DataFrame({"a": ["a", "b"]}) 1795s df["b"] = dda 1795s df["c"] = dda 1795s df.loc[[False, True], "b"] = 100 1795s result = df.loc[[1], :] 1795s expected = DataFrame({"a": ["b"], "b": [100], "c": [2]}, index=[1]) 1795s > tm.assert_frame_equal(result, expected) 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:256: 1795s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1795s 1795s left = array([100]), right = array([2]), err_msg = None 1795s 1795s def _raise(left, right, err_msg) -> NoReturn: 1795s if err_msg is None: 1795s if left.shape != right.shape: 1795s raise_assert_detail( 1795s obj, f"{obj} shapes are different", left.shape, right.shape 1795s ) 1795s 1795s diff = 0 1795s for left_arr, right_arr in zip(left, right): 1795s # count up differences 1795s if not array_equivalent(left_arr, right_arr, strict_nan=strict_nan): 1795s diff += 1 1795s 1795s diff = diff * 100.0 / left.size 1795s msg = f"{obj} values are different ({np.round(diff, 5)} %)" 1795s > raise_assert_detail(obj, msg, left, right, index_values=index_values) 1795s E AssertionError: DataFrame.iloc[:, 2] (column name="c") are different 1795s E 1795s E DataFrame.iloc[:, 2] (column name="c") values are different (100.0 %) 1795s E [index]: [1] 1795s E [left]: [100] 1795s E [right]: [2] 1795s 1795s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:684: AssertionError 1795s ________ TestDataFrameToXArray.test_to_xarray_index_types[datetime-tz] _________ 1795s self = 1795s index_flat = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1795s '2020-01-03 00:00:00-08:00', '... '2020-04-08 00:00:00-07:00', '2020-04-09 00:00:00-07:00'], 1795s dtype='datetime64[ns, US/Pacific]', freq='D') 1795s df = bar a b c ... f g h 1795s foo .....03 00:00:00-05:00 1795s 2020-01-04 00:00:00-08:00 d 4 6 ... d 2013-01-04 2013-01-04 00:00:00-05:00 1795s 1795s [4 rows x 8 columns] 1795s using_infer_string = False 1795s 1795s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1795s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1795s index = index_flat 1795s # MultiIndex is tested in test_to_xarray_with_multiindex 1795s if len(index) == 0: 1795s pytest.skip("Test doesn't make sense for empty index") 1795s 1795s from xarray import Dataset 1795s 1795s df.index = index[:4] 1795s df.index.name = "foo" 1795s df.columns.name = "bar" 1795s result = df.to_xarray() 1795s assert result.sizes["foo"] == 4 1795s assert len(result.coords) == 1 1795s assert len(result.data_vars) == 8 1795s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1795s assert isinstance(result, Dataset) 1795s 1795s # idempotency 1795s # datetimes w/tz are preserved 1795s # column names are lost 1795s expected = df.copy() 1795s # breaks in xarray >= 2024.10.0(?) 1795s # debug print 1795s r0 = result.to_dataframe() 1795s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1795s expected.columns.name = None 1795s > tm.assert_frame_equal(result.to_dataframe(), expected) 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1795s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1795s 1795s left = Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 1795s 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 1795s dtype='object', name='foo') 1795s right = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1795s '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 1795s dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 1795s obj = 'DataFrame.index' 1795s 1795s def _check_types(left, right, obj: str = "Index") -> None: 1795s if not exact: 1795s return 1795s 1795s > assert_class_equal(left, right, exact=exact, obj=obj) 1795s E AssertionError: DataFrame.index are different 1795s E 1795s E DataFrame.index classes are different 1795s E [left]: Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 1795s E 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 1795s E dtype='object', name='foo') 1795s E [right]: DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1795s E '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 1795s E dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 1795s 1795s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 1795s ________ TestDataFrameToXArray.test_to_xarray_index_types[bool-object] _________ 1795s self = 1795s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='object') 1795s df = bar a b c d e f g h 1795s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1795s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1795s using_infer_string = False 1795s 1795s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1795s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1795s index = index_flat 1795s # MultiIndex is tested in test_to_xarray_with_multiindex 1795s if len(index) == 0: 1795s pytest.skip("Test doesn't make sense for empty index") 1795s 1795s from xarray import Dataset 1795s 1795s df.index = index[:4] 1795s df.index.name = "foo" 1795s df.columns.name = "bar" 1795s result = df.to_xarray() 1795s assert result.sizes["foo"] == 4 1795s assert len(result.coords) == 1 1795s assert len(result.data_vars) == 8 1795s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1795s assert isinstance(result, Dataset) 1795s 1795s # idempotency 1795s # datetimes w/tz are preserved 1795s # column names are lost 1795s expected = df.copy() 1795s # breaks in xarray >= 2024.10.0(?) 1795s # debug print 1795s r0 = result.to_dataframe() 1795s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1795s expected.columns.name = None 1795s > tm.assert_frame_equal(result.to_dataframe(), expected) 1795s E AssertionError: DataFrame are different 1795s E 1795s E DataFrame shape mismatch 1795s E [left]: (8, 8) 1795s E [right]: (4, 8) 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1795s _________ TestDataFrameToXArray.test_to_xarray_index_types[bool-dtype] _________ 1795s self = 1795s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='bool') 1795s df = bar a b c d e f g h 1795s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1795s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1795s using_infer_string = False 1795s 1795s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1795s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1795s index = index_flat 1795s # MultiIndex is tested in test_to_xarray_with_multiindex 1795s if len(index) == 0: 1795s pytest.skip("Test doesn't make sense for empty index") 1795s 1795s from xarray import Dataset 1795s 1795s df.index = index[:4] 1795s df.index.name = "foo" 1795s df.columns.name = "bar" 1795s result = df.to_xarray() 1795s assert result.sizes["foo"] == 4 1795s assert len(result.coords) == 1 1795s assert len(result.data_vars) == 8 1795s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1795s assert isinstance(result, Dataset) 1795s 1795s # idempotency 1795s # datetimes w/tz are preserved 1795s # column names are lost 1795s expected = df.copy() 1795s # breaks in xarray >= 2024.10.0(?) 1795s # debug print 1795s r0 = result.to_dataframe() 1795s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1795s expected.columns.name = None 1795s > tm.assert_frame_equal(result.to_dataframe(), expected) 1795s E AssertionError: DataFrame are different 1795s E 1795s E DataFrame shape mismatch 1795s E [left]: (8, 8) 1795s E [right]: (4, 8) 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1795s ________ TestDataFrameToXArray.test_to_xarray_index_types[categorical] _________ 1795s self = 1795s index_flat = CategoricalIndex(['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 1795s 'a', 'b', 'c', 'd', 'a... 'a', 'b', 'c', 'd'], 1795s categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category') 1795s df = bar a b c d e f g h 1795s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1795s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1795s using_infer_string = False 1795s 1795s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1795s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1795s index = index_flat 1795s # MultiIndex is tested in test_to_xarray_with_multiindex 1795s if len(index) == 0: 1795s pytest.skip("Test doesn't make sense for empty index") 1795s 1795s from xarray import Dataset 1795s 1795s df.index = index[:4] 1795s df.index.name = "foo" 1795s df.columns.name = "bar" 1795s result = df.to_xarray() 1795s assert result.sizes["foo"] == 4 1795s assert len(result.coords) == 1 1795s assert len(result.data_vars) == 8 1795s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1795s assert isinstance(result, Dataset) 1795s 1795s # idempotency 1795s # datetimes w/tz are preserved 1795s # column names are lost 1795s expected = df.copy() 1795s # breaks in xarray >= 2024.10.0(?) 1795s # debug print 1795s r0 = result.to_dataframe() 1795s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1795s expected.columns.name = None 1795s > tm.assert_frame_equal(result.to_dataframe(), expected) 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1795s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1795s 1795s left = Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 1795s right = CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 1795s obj = 'DataFrame.index' 1795s 1795s def _check_types(left, right, obj: str = "Index") -> None: 1795s if not exact: 1795s return 1795s 1795s > assert_class_equal(left, right, exact=exact, obj=obj) 1795s E AssertionError: DataFrame.index are different 1795s E 1795s E DataFrame.index classes are different 1795s E [left]: Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 1795s E [right]: CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 1795s 1795s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 1795s __________ TestDataFrameToXArray.test_to_xarray_index_types[repeats] ___________ 1795s self = 1795s index_flat = Index([0, 0, 1, 1, 2, 2], dtype='int64') 1795s df = bar a b c d e f g h 1795s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1795s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1795s using_infer_string = False 1795s 1795s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1795s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1795s index = index_flat 1795s # MultiIndex is tested in test_to_xarray_with_multiindex 1795s if len(index) == 0: 1795s pytest.skip("Test doesn't make sense for empty index") 1795s 1795s from xarray import Dataset 1795s 1795s df.index = index[:4] 1795s df.index.name = "foo" 1795s df.columns.name = "bar" 1795s result = df.to_xarray() 1795s assert result.sizes["foo"] == 4 1795s assert len(result.coords) == 1 1795s assert len(result.data_vars) == 8 1795s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1795s assert isinstance(result, Dataset) 1795s 1795s # idempotency 1795s # datetimes w/tz are preserved 1795s # column names are lost 1795s expected = df.copy() 1795s # breaks in xarray >= 2024.10.0(?) 1795s # debug print 1795s r0 = result.to_dataframe() 1795s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1795s expected.columns.name = None 1795s > tm.assert_frame_equal(result.to_dataframe(), expected) 1795s E AssertionError: DataFrame are different 1795s E 1795s E DataFrame shape mismatch 1795s E [left]: (8, 8) 1795s E [right]: (4, 8) 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1795s ________ TestDataFrameToXArray.test_to_xarray_index_types[nullable_int] ________ 1795s self = 1795s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1795s 18, 19, 20, 21, 22, 23, 24, 25, ...7, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 1795s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 1795s dtype='Int64') 1795s df = bar a b c d e f g h 1795s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1795s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1795s using_infer_string = False 1795s 1795s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1795s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1795s index = index_flat 1795s # MultiIndex is tested in test_to_xarray_with_multiindex 1795s if len(index) == 0: 1795s pytest.skip("Test doesn't make sense for empty index") 1795s 1795s from xarray import Dataset 1795s 1795s df.index = index[:4] 1795s df.index.name = "foo" 1795s df.columns.name = "bar" 1795s result = df.to_xarray() 1795s assert result.sizes["foo"] == 4 1795s assert len(result.coords) == 1 1795s assert len(result.data_vars) == 8 1795s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1795s assert isinstance(result, Dataset) 1795s 1795s # idempotency 1795s # datetimes w/tz are preserved 1795s # column names are lost 1795s expected = df.copy() 1795s # breaks in xarray >= 2024.10.0(?) 1795s # debug print 1795s r0 = result.to_dataframe() 1795s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1795s expected.columns.name = None 1795s > tm.assert_frame_equal(result.to_dataframe(), expected) 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1795s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1795s 1795s left = Index([0, 1, 2, 3], dtype='object', name='foo') 1795s right = Index([0, 1, 2, 3], dtype='Int64', name='foo'), obj = 'DataFrame.index' 1795s 1795s def _check_types(left, right, obj: str = "Index") -> None: 1795s if not exact: 1795s return 1795s 1795s assert_class_equal(left, right, exact=exact, obj=obj) 1795s assert_attr_equal("inferred_type", left, right, obj=obj) 1795s 1795s # Skip exact dtype checking when `check_categorical` is False 1795s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1795s right.dtype, CategoricalDtype 1795s ): 1795s if check_categorical: 1795s assert_attr_equal("dtype", left, right, obj=obj) 1795s assert_index_equal(left.categories, right.categories, exact=exact) 1795s return 1795s 1795s > assert_attr_equal("dtype", left, right, obj=obj) 1795s E AssertionError: DataFrame.index are different 1795s E 1795s E Attribute "dtype" are different 1795s E [left]: object 1795s E [right]: Int64 1795s 1795s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1795s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_uint] ________ 1795s self = 1795s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1795s 18, 19, 20, 21, 22, 23, 24, 25, ..., 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 1795s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 1795s dtype='UInt16') 1795s df = bar a b c d e f g h 1795s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1795s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1795s using_infer_string = False 1795s 1795s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1795s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1795s index = index_flat 1795s # MultiIndex is tested in test_to_xarray_with_multiindex 1795s if len(index) == 0: 1795s pytest.skip("Test doesn't make sense for empty index") 1795s 1795s from xarray import Dataset 1795s 1795s df.index = index[:4] 1795s df.index.name = "foo" 1795s df.columns.name = "bar" 1795s result = df.to_xarray() 1795s assert result.sizes["foo"] == 4 1795s assert len(result.coords) == 1 1795s assert len(result.data_vars) == 8 1795s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1795s assert isinstance(result, Dataset) 1795s 1795s # idempotency 1795s # datetimes w/tz are preserved 1795s # column names are lost 1795s expected = df.copy() 1795s # breaks in xarray >= 2024.10.0(?) 1795s # debug print 1795s r0 = result.to_dataframe() 1795s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1795s expected.columns.name = None 1795s > tm.assert_frame_equal(result.to_dataframe(), expected) 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1795s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1795s 1795s left = Index([0, 1, 2, 3], dtype='object', name='foo') 1795s right = Index([0, 1, 2, 3], dtype='UInt16', name='foo'), obj = 'DataFrame.index' 1795s 1795s def _check_types(left, right, obj: str = "Index") -> None: 1795s if not exact: 1795s return 1795s 1795s assert_class_equal(left, right, exact=exact, obj=obj) 1795s assert_attr_equal("inferred_type", left, right, obj=obj) 1795s 1795s # Skip exact dtype checking when `check_categorical` is False 1795s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1795s right.dtype, CategoricalDtype 1795s ): 1795s if check_categorical: 1795s assert_attr_equal("dtype", left, right, obj=obj) 1795s assert_index_equal(left.categories, right.categories, exact=exact) 1795s return 1795s 1795s > assert_attr_equal("dtype", left, right, obj=obj) 1795s E AssertionError: DataFrame.index are different 1795s E 1795s E Attribute "dtype" are different 1795s E [left]: object 1795s E [right]: UInt16 1795s 1795s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1795s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_float] _______ 1795s self = 1795s 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, 1795s 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, 1795s 96.0, 97.0, 98.0, 99.0], 1795s dtype='Float32') 1795s df = bar a b c d e f g h 1795s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1795s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1795s using_infer_string = False 1795s 1795s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1795s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1795s index = index_flat 1795s # MultiIndex is tested in test_to_xarray_with_multiindex 1795s if len(index) == 0: 1795s pytest.skip("Test doesn't make sense for empty index") 1795s 1795s from xarray import Dataset 1795s 1795s df.index = index[:4] 1795s df.index.name = "foo" 1795s df.columns.name = "bar" 1795s result = df.to_xarray() 1795s assert result.sizes["foo"] == 4 1795s assert len(result.coords) == 1 1795s assert len(result.data_vars) == 8 1795s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1795s assert isinstance(result, Dataset) 1795s 1795s # idempotency 1795s # datetimes w/tz are preserved 1795s # column names are lost 1795s expected = df.copy() 1795s # breaks in xarray >= 2024.10.0(?) 1795s # debug print 1795s r0 = result.to_dataframe() 1795s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1795s expected.columns.name = None 1795s > tm.assert_frame_equal(result.to_dataframe(), expected) 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1795s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1795s 1795s left = Index([0.0, 1.0, 2.0, 3.0], dtype='object', name='foo') 1795s right = Index([0.0, 1.0, 2.0, 3.0], dtype='Float32', name='foo') 1795s obj = 'DataFrame.index' 1795s 1795s def _check_types(left, right, obj: str = "Index") -> None: 1795s if not exact: 1795s return 1795s 1795s assert_class_equal(left, right, exact=exact, obj=obj) 1795s assert_attr_equal("inferred_type", left, right, obj=obj) 1795s 1795s # Skip exact dtype checking when `check_categorical` is False 1795s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1795s right.dtype, CategoricalDtype 1795s ): 1795s if check_categorical: 1795s assert_attr_equal("dtype", left, right, obj=obj) 1795s assert_index_equal(left.categories, right.categories, exact=exact) 1795s return 1795s 1795s > assert_attr_equal("dtype", left, right, obj=obj) 1795s E AssertionError: DataFrame.index are different 1795s E 1795s E Attribute "dtype" are different 1795s E [left]: object 1795s E [right]: Float32 1795s 1795s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1795s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_bool] ________ 1795s self = 1795s index_flat = Index([False, True, True, True, True, True, True, True, True, True, 1795s True, True, True, True, True,...rue, True, True, 1795s True, True, True, True, True, True, True, True, True, True], 1795s dtype='boolean') 1795s df = bar a b c d e f g h 1795s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1795s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1795s using_infer_string = False 1795s 1795s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1795s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1795s index = index_flat 1795s # MultiIndex is tested in test_to_xarray_with_multiindex 1795s if len(index) == 0: 1795s pytest.skip("Test doesn't make sense for empty index") 1795s 1795s from xarray import Dataset 1795s 1795s df.index = index[:4] 1795s df.index.name = "foo" 1795s df.columns.name = "bar" 1795s result = df.to_xarray() 1795s assert result.sizes["foo"] == 4 1795s assert len(result.coords) == 1 1795s assert len(result.data_vars) == 8 1795s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1795s assert isinstance(result, Dataset) 1795s 1795s # idempotency 1795s # datetimes w/tz are preserved 1795s # column names are lost 1795s expected = df.copy() 1795s # breaks in xarray >= 2024.10.0(?) 1795s # debug print 1795s r0 = result.to_dataframe() 1795s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1795s expected.columns.name = None 1795s > tm.assert_frame_equal(result.to_dataframe(), expected) 1795s E AssertionError: DataFrame are different 1795s E 1795s E DataFrame shape mismatch 1795s E [left]: (10, 8) 1795s E [right]: (4, 8) 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1795s _______ TestDataFrameToXArray.test_to_xarray_index_types[string-python] ________ 1795s self = 1795s index_flat = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3', 'pandas_4', 'pandas_5', 1795s 'pandas_6', 'pandas_7', 'pandas_...pandas_93', 'pandas_94', 'pandas_95', 1795s 'pandas_96', 'pandas_97', 'pandas_98', 'pandas_99'], 1795s dtype='string') 1795s df = bar a b c d e f g h 1795s foo ....0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1795s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1795s using_infer_string = False 1795s 1795s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1795s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1795s index = index_flat 1795s # MultiIndex is tested in test_to_xarray_with_multiindex 1795s if len(index) == 0: 1795s pytest.skip("Test doesn't make sense for empty index") 1795s 1795s from xarray import Dataset 1795s 1795s df.index = index[:4] 1795s df.index.name = "foo" 1795s df.columns.name = "bar" 1795s result = df.to_xarray() 1795s assert result.sizes["foo"] == 4 1795s assert len(result.coords) == 1 1795s assert len(result.data_vars) == 8 1795s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1795s assert isinstance(result, Dataset) 1795s 1795s # idempotency 1795s # datetimes w/tz are preserved 1795s # column names are lost 1795s expected = df.copy() 1795s # breaks in xarray >= 2024.10.0(?) 1795s # debug print 1795s r0 = result.to_dataframe() 1795s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1795s expected.columns.name = None 1795s > tm.assert_frame_equal(result.to_dataframe(), expected) 1795s 1795s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1795s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1795s 1795s left = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 1795s right = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='string', name='foo') 1795s obj = 'DataFrame.index' 1795s 1795s def _check_types(left, right, obj: str = "Index") -> None: 1795s if not exact: 1795s return 1795s 1795s assert_class_equal(left, right, exact=exact, obj=obj) 1795s assert_attr_equal("inferred_type", left, right, obj=obj) 1795s 1795s # Skip exact dtype checking when `check_categorical` is False 1795s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1795s right.dtype, CategoricalDtype 1795s ): 1795s if check_categorical: 1795s assert_attr_equal("dtype", left, right, obj=obj) 1795s assert_index_equal(left.categories, right.categories, exact=exact) 1795s return 1795s 1795s > assert_attr_equal("dtype", left, right, obj=obj) 1795s E AssertionError: DataFrame.index are different 1795s E 1795s E Attribute "dtype" are different 1795s E [left]: object 1795s E [right]: string[python] 1795s 1795s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1795s =============================== warnings summary =============================== 1795s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:39 1795s /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 1795s pytestmark = pytest.mark.single_cpu 1795s 1795s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:30 1795s /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 1795s pytestmark = pytest.mark.single_cpu 1795s 1795s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:39 1795s /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 1795s pytestmark = pytest.mark.single_cpu 1795s 1795s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:119 1795s /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 1795s @pytest.mark.single_cpu 1795s 1795s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:125 1795s /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 1795s @pytest.mark.single_cpu 1795s 1795s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:196 1795s /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 1795s @pytest.mark.single_cpu 1795s 1795s io/pytables/test_file_handling.py: 191 warnings 1795s io/pytables/test_append.py: 21 warnings 1795s io/pytables/test_store.py: 66 warnings 1795s test_downstream.py: 26 warnings 1795s generic/test_to_xarray.py: 62 warnings 1795s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=17002) is multi-threaded, use of fork() may lead to deadlocks in the child. 1795s pid = os.fork() 1795s 1795s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1795s /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-dqckoooi' 1795s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1795s 1795s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 1795s /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-iw2bg__k' 1795s config.cache.set("cache/lastfailed", self.lastfailed) 1795s 1795s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1795s /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-4fzyo_ng' 1795s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1795s 1795s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1795s =========================== short test summary info ============================ 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-1] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-2] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-3] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-4] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-5] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-6] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-7] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-8] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-9] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py::test_append_frame_column_oriented 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py::test_select_filter_corner 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py::test_frame_setitem_dask_array_into_new_col 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime-tz] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-object] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-dtype] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[categorical] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[repeats] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_int] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_uint] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_float] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_bool] 1795s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string-python] 1795s =========== 22 failed, 335 passed, 9 skipped, 375 warnings in 32.46s =========== 1795s pymysql/psycopg2 tests, which do not work in this test environment 1796s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1796s 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" 1796s 1796s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1798s ============================= test session starts ============================== 1798s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1798s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1798s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1798s 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 1798s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1798s collected 2513 items 1798s 2590s ../../../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................ 2624s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss......................................................................................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 2624s 2624s ==================================== ERRORS ==================================== 2624s _______ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_engine] _______ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ________ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_conn] ________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_engine] ____ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_conn] _____ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_engine] ____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_conn] _____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_engine] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s __ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_conn] __ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _________ ERROR at teardown of test_to_sql[None-mysql_pymysql_engine] __________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s __________ ERROR at teardown of test_to_sql[None-mysql_pymysql_conn] ___________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_engine] _______ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_conn] ________ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_engine] _________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s __________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_conn] __________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_engine] ______ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_conn] _______ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_engine] ____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_conn] _____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_engine] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s __ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_conn] __ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_engine] _____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_conn] ______ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_engine] __ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s __ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_conn] ___ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_engine] _______ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_conn] ________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ___ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_engine] ____ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ____ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_conn] _____ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _____ ERROR at teardown of test_read_iris_query[mysql_pymysql_engine_iris] _____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ______ ERROR at teardown of test_read_iris_query[mysql_pymysql_conn_iris] ______ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s __ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_engine_iris] __ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ___ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_conn_iris] ___ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_engine_iris] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_conn_iris] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _____ ERROR at teardown of test_read_iris_table[mysql_pymysql_engine_iris] _____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ______ ERROR at teardown of test_read_iris_table[mysql_pymysql_conn_iris] ______ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s __ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_engine_iris] __ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ___ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_conn_iris] ___ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_engine_iris] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_conn_iris] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _______ ERROR at teardown of test_to_sql_callable[mysql_pymysql_engine] ________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ________ ERROR at teardown of test_to_sql_callable[mysql_pymysql_conn] _________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_engine] _____ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_conn] ______ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_engine_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_conn_types] __ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ________ ERROR at teardown of test_read_procedure[mysql_pymysql_engine] ________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _________ ERROR at teardown of test_read_procedure[mysql_pymysql_conn] _________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_engine] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_conn] __ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_engine] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_conn] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ___ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_engine] ___ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ____ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_conn] ____ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_engine_iris] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s __ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_conn_iris] __ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_engine_iris] ____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_conn_iris] _____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_engine_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s __ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_conn_iris] __ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s __________ ERROR at teardown of test_api_to_sql[mysql_pymysql_engine] __________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ___________ ERROR at teardown of test_api_to_sql[mysql_pymysql_conn] ___________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _______ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_engine] _______ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ________ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_conn] ________ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _______ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_engine] ________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ________ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_conn] _________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_engine] _____ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_conn] ______ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_engine] ______ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_conn] _______ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ___ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_engine] ___ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ____ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_conn] ____ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_engine] _______ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_conn] ________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ___ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_engine] ____ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ____ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_conn] _____ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ___ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_engine] ____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ____ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_conn] _____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_engine] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_conn] __ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_engine] _______ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_conn] ________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ___ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_engine] ____ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ____ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_conn] _____ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_engine] _________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_conn] __________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _____ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_engine] ______ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ______ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_conn] _______ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ___ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_engine] ____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ____ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_conn] _____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_engine] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_conn] __ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _____ ERROR at teardown of test_api_execute_sql[mysql_pymysql_engine_iris] _____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ______ ERROR at teardown of test_api_execute_sql[mysql_pymysql_conn_iris] ______ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s __ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_engine_iris] __ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ___ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_conn_iris] ___ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_engine_types] ____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_conn_types] _____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s __ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_conn_types] __ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ___ ERROR at teardown of test_api_date_and_index[mysql_pymysql_engine_types] ___ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ____ ERROR at teardown of test_api_date_and_index[mysql_pymysql_conn_types] ____ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_engine_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_conn_types] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ________ ERROR at teardown of test_api_timedelta[mysql_pymysql_engine] _________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _________ ERROR at teardown of test_api_timedelta[mysql_pymysql_conn] __________ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _____ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_engine] ______ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ______ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_conn] _______ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_engine] ______ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_conn] _______ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s ___ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_engine] ___ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s ____ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_conn] ____ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] _ 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s > sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3.13/socket.py:864: in create_connection 2624s raise exceptions[0] 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s address = ('localhost', 3306), timeout = 10, source_address = None 2624s 2624s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2624s source_address=None, *, all_errors=False): 2624s """Connect to *address* and return the socket object. 2624s 2624s Convenience function. Connect to *address* (a 2-tuple ``(host, 2624s port)``) and return the socket object. Passing the optional 2624s *timeout* parameter will set the timeout on the socket instance 2624s before attempting to connect. If no *timeout* is supplied, the 2624s global default timeout setting returned by :func:`getdefaulttimeout` 2624s is used. If *source_address* is set it must be a tuple of (host, port) 2624s for the socket to bind as a source address before making the connection. 2624s A host of '' or port 0 tells the OS to use the default. When a connection 2624s cannot be created, raises the last error if *all_errors* is False, 2624s and an ExceptionGroup of all errors if *all_errors* is True. 2624s """ 2624s 2624s host, port = address 2624s exceptions = [] 2624s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2624s af, socktype, proto, canonname, sa = res 2624s sock = None 2624s try: 2624s sock = socket(af, socktype, proto) 2624s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2624s sock.settimeout(timeout) 2624s if source_address: 2624s sock.bind(source_address) 2624s > sock.connect(sa) 2624s E ConnectionRefusedError: [Errno 111] Connection refused 2624s 2624s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2624s 2624s During handling of the above exception, another exception occurred: 2624s 2624s self = 2624s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2624s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def mysql_pymysql_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s pymysql = td.versioned_importorskip("pymysql") 2624s engine = sqlalchemy.create_engine( 2624s "mysql+pymysql://root@localhost:3306/pandas", 2624s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2624s self.connect() 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s self = , sock = None 2624s 2624s def connect(self, sock=None): 2624s self._closed = False 2624s try: 2624s if sock is None: 2624s if self.unix_socket: 2624s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2624s sock.settimeout(self.connect_timeout) 2624s sock.connect(self.unix_socket) 2624s self.host_info = "Localhost via UNIX socket" 2624s self._secure = True 2624s if DEBUG: 2624s print("connected using unix_socket") 2624s else: 2624s kwargs = {} 2624s if self.bind_address is not None: 2624s kwargs["source_address"] = (self.bind_address, 0) 2624s while True: 2624s try: 2624s sock = socket.create_connection( 2624s (self.host, self.port), self.connect_timeout, **kwargs 2624s ) 2624s break 2624s except OSError as e: 2624s if e.errno == errno.EINTR: 2624s continue 2624s raise 2624s self.host_info = "socket %s:%d" % (self.host, self.port) 2624s if DEBUG: 2624s print("connected using socket") 2624s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2624s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2624s sock.settimeout(None) 2624s 2624s self._sock = sock 2624s self._rfile = sock.makefile("rb") 2624s self._next_seq_id = 0 2624s 2624s self._get_server_information() 2624s self._request_authentication() 2624s 2624s # Send "SET NAMES" query on init for: 2624s # - Ensure charaset (and collation) is set to the server. 2624s # - collation_id in handshake packet may be ignored. 2624s # - If collation is not specified, we don't know what is server's 2624s # default collation for the charset. For example, default collation 2624s # of utf8mb4 is: 2624s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2624s # - MySQL 8.0: utf8mb4_0900_ai_ci 2624s # 2624s # Reference: 2624s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2624s # - https://github.com/wagtail/wagtail/issues/9477 2624s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2624s self.set_character_set(self.charset, self.collation) 2624s 2624s if self.sql_mode is not None: 2624s c = self.cursor() 2624s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2624s c.close() 2624s 2624s if self.init_command is not None: 2624s c = self.cursor() 2624s c.execute(self.init_command) 2624s c.close() 2624s 2624s if self.autocommit_mode is not None: 2624s self.autocommit(self.autocommit_mode) 2624s except BaseException as e: 2624s self._rfile = None 2624s if sock is not None: 2624s try: 2624s sock.close() 2624s except: # noqa 2624s pass 2624s 2624s if isinstance(e, (OSError, IOError)): 2624s exc = err.OperationalError( 2624s CR.CR_CONN_HOST_ERROR, 2624s f"Can't connect to MySQL server on {self.host!r} ({e})", 2624s ) 2624s # Keep original exception and traceback to investigate error. 2624s exc.original_exception = e 2624s exc.traceback = traceback.format_exc() 2624s if DEBUG: 2624s print(exc.traceback) 2624s > raise exc 2624s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2624s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2624s 2624s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2624s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _ 2624s self = 2624s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2624s connection = None, _has_events = None, _allow_revalidate = True 2624s _allow_autobegin = True 2624s 2624s def __init__( 2624s self, 2624s engine: Engine, 2624s connection: Optional[PoolProxiedConnection] = None, 2624s _has_events: Optional[bool] = None, 2624s _allow_revalidate: bool = True, 2624s _allow_autobegin: bool = True, 2624s ): 2624s """Construct a new Connection.""" 2624s self.engine = engine 2624s self.dialect = dialect = engine.dialect 2624s 2624s if connection is None: 2624s try: 2624s > self._dbapi_connection = engine.raw_connection() 2624s 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2624s 2624s Any other keyword parameter will be passed to the underlying client 2624s library: the list of supported parameters depends on the library version. 2624s 2624s """ 2624s kwasync = {} 2624s if 'async' in kwargs: 2624s kwasync['async'] = kwargs.pop('async') 2624s if 'async_' in kwargs: 2624s kwasync['async_'] = kwargs.pop('async_') 2624s 2624s dsn = _ext.make_dsn(dsn, **kwargs) 2624s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2624s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2624s E Is the server running on that host and accepting TCP/IP connections? 2624s 2624s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2624s 2624s The above exception was the direct cause of the following exception: 2624s 2624s @pytest.fixture 2624s def postgresql_psycopg2_engine(): 2624s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2624s td.versioned_importorskip("psycopg2") 2624s engine = sqlalchemy.create_engine( 2624s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2624s poolclass=sqlalchemy.pool.NullPool, 2624s ) 2624s yield engine 2624s > for view in get_all_views(engine): 2624s 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2624s return inspect(conn).get_view_names() 2624s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2624s ret = reg(subject) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2624s return Inspector._construct(Inspector._init_engine, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2624s init(self, bind) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2624s engine.connect().close() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2624s return self._connection_cls(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2624s Connection._handle_dbapi_exception_noconnection( 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2624s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2624s self._dbapi_connection = engine.raw_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2624s return self.pool.connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2624s return _ConnectionFairy._checkout(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2624s fairy = _ConnectionRecord.checkout(pool) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2624s rec = pool._do_get() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2624s return self._create_connection() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2624s return _ConnectionRecord(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2624s self.__connect() 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2624s with util.safe_reraise(): 2624s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2624s raise exc_value.with_traceback(exc_tb) 2624s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2624s self.dbapi_connection = connection = pool._invoke_creator(self) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2624s return dialect.connect(*cargs, **cparams) 2624s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2624s return self.loaded_dbapi.connect(*cargs, **cparams) 2624s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2624s 2624s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2624s connection_factory = None, cursor_factory = None 2624s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2624s kwasync = {} 2624s 2624s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2624s """ 2624s Create a new database connection. 2624s 2624s The connection parameters can be specified as a string: 2624s 2624s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2624s 2624s or using a set of keyword arguments: 2624s 2624s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2624s 2624s Or as a mix of both. The basic connection parameters are: 2624s 2624s - *dbname*: the database name 2624s - *database*: the database name (only as keyword argument) 2624s - *user*: user name used to authenticate 2624s - *password*: password used to authenticate 2624s - *host*: database host address (defaults to UNIX socket if not provided) 2624s - *port*: connection port number (defaults to 5432 if not provided) 2624s 2624s Using the *connection_factory* parameter a different class or connections 2624s factory can be specified. It should be a callable object taking a dsn 2624s argument. 2624s 2624s Using the *cursor_factory* parameter, a new default cursor factory will be 2624s used by cursor(). 2624s 2624s Using *async*=True an asynchronous connection will be created. *async_* is 2624s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_engine] ___ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_conn] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_engine] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_conn] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_conn] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_engine] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_conn] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_conn] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_engine] ___ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_conn] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_engine] ___ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_conn] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_engine] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_conn] ______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_engine] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_conn] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________ ERROR at teardown of test_api_get_schema[mysql_pymysql_engine] ________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _________ ERROR at teardown of test_api_get_schema[mysql_pymysql_conn] _________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_engine] _____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_conn] ______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_engine] __ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_conn] ___ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_engine] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_conn] ______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_engine] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_conn] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _____ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_engine] ______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_conn] _______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_engine] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_conn] ____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_engine] ______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_conn] _______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_engine] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_conn] ____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______ ERROR at teardown of test_api_categorical[mysql_pymysql_engine] ________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ________ ERROR at teardown of test_api_categorical[mysql_pymysql_conn] _________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_engine] _____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_conn] ______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_engine] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_conn] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_conn] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_engine] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_conn] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_conn] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______ ERROR at teardown of test_read_table_columns[mysql_pymysql_engine] ______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______ ERROR at teardown of test_read_table_columns[mysql_pymysql_conn] _______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_engine] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_conn] ____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _____ ERROR at teardown of test_read_table_index_col[mysql_pymysql_engine] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______ ERROR at teardown of test_read_table_index_col[mysql_pymysql_conn] ______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_engine] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_conn] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_engine_iris] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_conn_iris] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_engine_iris] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_conn_iris] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_engine] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_conn] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _____ ERROR at teardown of test_database_uri_string[mysql_pymysql_engine] ______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______ ERROR at teardown of test_database_uri_string[mysql_pymysql_conn] _______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_engine] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_conn] ____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_engine_iris] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_conn_iris] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_engine_iris] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_conn_iris] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_engine_iris] ___ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_conn_iris] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_engine_iris] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_conn_iris] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_engine] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_conn] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_conn] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________ ERROR at teardown of test_create_table[mysql_pymysql_engine] _________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __________ ERROR at teardown of test_create_table[mysql_pymysql_conn] __________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______ ERROR at teardown of test_create_table[postgresql_psycopg2_engine] ______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______ ERROR at teardown of test_create_table[postgresql_psycopg2_conn] _______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __________ ERROR at teardown of test_drop_table[mysql_pymysql_engine] __________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________ ERROR at teardown of test_drop_table[mysql_pymysql_conn] ___________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______ ERROR at teardown of test_drop_table[postgresql_psycopg2_engine] _______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________ ERROR at teardown of test_drop_table[postgresql_psycopg2_conn] ________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __________ ERROR at teardown of test_roundtrip[mysql_pymysql_engine] ___________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________ ERROR at teardown of test_roundtrip[mysql_pymysql_conn] ____________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______ ERROR at teardown of test_roundtrip[postgresql_psycopg2_engine] ________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________ ERROR at teardown of test_roundtrip[postgresql_psycopg2_conn] _________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______ ERROR at teardown of test_execute_sql[mysql_pymysql_engine_iris] _______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ________ ERROR at teardown of test_execute_sql[mysql_pymysql_conn_iris] ________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_engine_iris] ____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_conn_iris] _____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_engine_iris] __ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ___ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_engine_iris] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_conn_iris] __ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_engine_iris] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____________ ERROR at teardown of test_bigint[mysql_pymysql_engine] ____________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____________ ERROR at teardown of test_bigint[mysql_pymysql_conn] _____________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _________ ERROR at teardown of test_bigint[postgresql_psycopg2_engine] _________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __________ ERROR at teardown of test_bigint[postgresql_psycopg2_conn] __________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___ ERROR at teardown of test_default_date_load[mysql_pymysql_engine_types] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____ ERROR at teardown of test_default_date_load[mysql_pymysql_conn_types] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_engine_types] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_conn_types] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_engine] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_conn] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_conn] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] __ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______ ERROR at teardown of test_date_parsing[mysql_pymysql_engine_types] ______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______ ERROR at teardown of test_date_parsing[mysql_pymysql_conn_types] _______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___ ERROR at teardown of test_date_parsing[postgresql_psycopg2_engine_types] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_date_parsing[postgresql_psycopg2_conn_types] ____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___________ ERROR at teardown of test_datetime[mysql_pymysql_engine] ___________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____________ ERROR at teardown of test_datetime[mysql_pymysql_conn] ____________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ________ ERROR at teardown of test_datetime[postgresql_psycopg2_engine] ________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________ ERROR at teardown of test_datetime[postgresql_psycopg2_conn] _________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_engine] _________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_conn] __________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_engine] ______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_conn] _______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________ ERROR at teardown of test_datetime_date[mysql_pymysql_engine] _________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _________ ERROR at teardown of test_datetime_date[mysql_pymysql_conn] __________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_datetime_date[postgresql_psycopg2_engine] ______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______ ERROR at teardown of test_datetime_date[postgresql_psycopg2_conn] _______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________ ERROR at teardown of test_datetime_time[mysql_pymysql_engine] _________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _________ ERROR at teardown of test_datetime_time[mysql_pymysql_conn] __________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_datetime_time[postgresql_psycopg2_engine] ______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______ ERROR at teardown of test_datetime_time[postgresql_psycopg2_conn] _______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_engine] ______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_conn] _______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_engine] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_conn] ____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________ ERROR at teardown of test_nan_numeric[mysql_pymysql_engine] __________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __________ ERROR at teardown of test_nan_numeric[mysql_pymysql_conn] ___________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_engine] _______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_conn] ________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_engine] ________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_conn] _________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_engine] _____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_conn] ______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __________ ERROR at teardown of test_nan_string[mysql_pymysql_engine] __________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________ ERROR at teardown of test_nan_string[mysql_pymysql_conn] ___________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______ ERROR at teardown of test_nan_string[postgresql_psycopg2_engine] _______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________ ERROR at teardown of test_nan_string[postgresql_psycopg2_conn] ________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_engine] _______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_conn] ________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_engine] ____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_conn] _____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________ ERROR at teardown of test_transactions[mysql_pymysql_engine] _________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __________ ERROR at teardown of test_transactions[mysql_pymysql_conn] __________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______ ERROR at teardown of test_transactions[postgresql_psycopg2_engine] ______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______ ERROR at teardown of test_transactions[postgresql_psycopg2_conn] _______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _____ ERROR at teardown of test_transaction_rollback[mysql_pymysql_engine] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______ ERROR at teardown of test_transaction_rollback[mysql_pymysql_conn] ______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_engine] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_conn] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_engine] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_conn] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_conn] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____________ ERROR at teardown of test_dtype[mysql_pymysql_engine] _____________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____________ ERROR at teardown of test_dtype[mysql_pymysql_conn] ______________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _________ ERROR at teardown of test_dtype[postgresql_psycopg2_engine] __________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __________ ERROR at teardown of test_dtype[postgresql_psycopg2_conn] ___________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________ ERROR at teardown of test_notna_dtype[mysql_pymysql_engine] __________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __________ ERROR at teardown of test_notna_dtype[mysql_pymysql_conn] ___________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_engine] _______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_conn] ________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______ ERROR at teardown of test_double_precision[mysql_pymysql_engine] _______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ________ ERROR at teardown of test_double_precision[mysql_pymysql_conn] ________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____ ERROR at teardown of test_double_precision[postgresql_psycopg2_engine] ____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _____ ERROR at teardown of test_double_precision[postgresql_psycopg2_conn] _____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_engine] ___ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_conn] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______ ERROR at teardown of test_temporary_table[mysql_pymysql_engine] ________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ________ ERROR at teardown of test_temporary_table[mysql_pymysql_conn] _________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_engine] _____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_conn] ______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________ ERROR at teardown of test_invalid_engine[mysql_pymysql_engine] ________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _________ ERROR at teardown of test_invalid_engine[mysql_pymysql_conn] _________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_engine] _____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_conn] ______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_engine] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_conn] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_conn] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_engine] ______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_conn] _______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_engine] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_conn] ____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________ ERROR at teardown of test_options_auto[mysql_pymysql_engine] _________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __________ ERROR at teardown of test_options_auto[mysql_pymysql_conn] __________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______ ERROR at teardown of test_options_auto[postgresql_psycopg2_engine] ______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______ ERROR at teardown of test_options_auto[postgresql_psycopg2_conn] _______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_engine] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_conn] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_conn] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def mysql_pymysql_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s pymysql = td.versioned_importorskip("pymysql") 2625s engine = sqlalchemy.create_engine( 2625s "mysql+pymysql://root@localhost:3306/pandas", 2625s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______________ ERROR at teardown of test_psycopg2_schema_support _______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______________ ERROR at teardown of test_self_join_date_columns _______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s @pytest.fixture 2625s def postgresql_psycopg2_engine(): 2625s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2625s td.versioned_importorskip("psycopg2") 2625s engine = sqlalchemy.create_engine( 2625s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2625s poolclass=sqlalchemy.pool.NullPool, 2625s ) 2625s yield engine 2625s > for view in get_all_views(engine): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2625s return inspect(conn).get_view_names() 2625s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2625s ret = reg(subject) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2625s return Inspector._construct(Inspector._init_engine, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2625s init(self, bind) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2625s engine.connect().close() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s =================================== FAILURES =================================== 2625s _________________ test_dataframe_to_sql[mysql_pymysql_engine] __________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_dataframe_to_sql(conn, test_frame1, request): 2625s # GH 51086 if conn is sqlite_engine 2625s conn = request.getfixturevalue(conn) 2625s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2625s return func(*args, **kwargs) 2625s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2625s return sql.to_sql( 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2625s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __________________ test_dataframe_to_sql[mysql_pymysql_conn] ___________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_dataframe_to_sql(conn, test_frame1, request): 2625s # GH 51086 if conn is sqlite_engine 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______________ test_dataframe_to_sql[postgresql_psycopg2_engine] _______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_dataframe_to_sql(conn, test_frame1, request): 2625s # GH 51086 if conn is sqlite_engine 2625s conn = request.getfixturevalue(conn) 2625s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2625s return func(*args, **kwargs) 2625s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2625s return sql.to_sql( 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2625s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______________ test_dataframe_to_sql[postgresql_psycopg2_conn] ________________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_dataframe_to_sql(conn, test_frame1, request): 2625s # GH 51086 if conn is sqlite_engine 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______________ test_dataframe_to_sql_empty[mysql_pymysql_engine] _______________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2625s if conn == "postgresql_adbc_conn": 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="postgres ADBC driver cannot insert index with null type", 2625s strict=True, 2625s ) 2625s ) 2625s # GH 51086 if conn is sqlite_engine 2625s conn = request.getfixturevalue(conn) 2625s empty_df = test_frame1.iloc[:0] 2625s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2625s return func(*args, **kwargs) 2625s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2625s return sql.to_sql( 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2625s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______________ test_dataframe_to_sql_empty[mysql_pymysql_conn] ________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2625s if conn == "postgresql_adbc_conn": 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="postgres ADBC driver cannot insert index with null type", 2625s strict=True, 2625s ) 2625s ) 2625s # GH 51086 if conn is sqlite_engine 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________ test_dataframe_to_sql_empty[postgresql_psycopg2_engine] ____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2625s if conn == "postgresql_adbc_conn": 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="postgres ADBC driver cannot insert index with null type", 2625s strict=True, 2625s ) 2625s ) 2625s # GH 51086 if conn is sqlite_engine 2625s conn = request.getfixturevalue(conn) 2625s empty_df = test_frame1.iloc[:0] 2625s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2625s return func(*args, **kwargs) 2625s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2625s return sql.to_sql( 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2625s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____________ test_dataframe_to_sql_empty[postgresql_psycopg2_conn] _____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2625s if conn == "postgresql_adbc_conn": 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="postgres ADBC driver cannot insert index with null type", 2625s strict=True, 2625s ) 2625s ) 2625s # GH 51086 if conn is sqlite_engine 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____________________ test_to_sql[None-mysql_pymysql_engine] ____________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = None 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("method", [None, "multi"]) 2625s def test_to_sql(conn, method, test_frame1, request): 2625s if method == "multi" and "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'method' not implemented for ADBC drivers", strict=True 2625s ) 2625s ) 2625s 2625s conn = request.getfixturevalue(conn) 2625s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____________________ test_to_sql[None-mysql_pymysql_conn] _____________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn', method = None 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("method", [None, "multi"]) 2625s def test_to_sql(conn, method, test_frame1, request): 2625s if method == "multi" and "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'method' not implemented for ADBC drivers", strict=True 2625s ) 2625s ) 2625s 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _________________ test_to_sql[None-postgresql_psycopg2_engine] _________________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s method = None 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("method", [None, "multi"]) 2625s def test_to_sql(conn, method, test_frame1, request): 2625s if method == "multi" and "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'method' not implemented for ADBC drivers", strict=True 2625s ) 2625s ) 2625s 2625s conn = request.getfixturevalue(conn) 2625s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __________________ test_to_sql[None-postgresql_psycopg2_conn] __________________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn', method = None 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("method", [None, "multi"]) 2625s def test_to_sql(conn, method, test_frame1, request): 2625s if method == "multi" and "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'method' not implemented for ADBC drivers", strict=True 2625s ) 2625s ) 2625s 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___________________ test_to_sql[multi-mysql_pymysql_engine] ____________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = 'multi' 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("method", [None, "multi"]) 2625s def test_to_sql(conn, method, test_frame1, request): 2625s if method == "multi" and "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'method' not implemented for ADBC drivers", strict=True 2625s ) 2625s ) 2625s 2625s conn = request.getfixturevalue(conn) 2625s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____________________ test_to_sql[multi-mysql_pymysql_conn] _____________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn', method = 'multi' 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("method", [None, "multi"]) 2625s def test_to_sql(conn, method, test_frame1, request): 2625s if method == "multi" and "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'method' not implemented for ADBC drivers", strict=True 2625s ) 2625s ) 2625s 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ________________ test_to_sql[multi-postgresql_psycopg2_engine] _________________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s method = 'multi' 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("method", [None, "multi"]) 2625s def test_to_sql(conn, method, test_frame1, request): 2625s if method == "multi" and "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'method' not implemented for ADBC drivers", strict=True 2625s ) 2625s ) 2625s 2625s conn = request.getfixturevalue(conn) 2625s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________________ test_to_sql[multi-postgresql_psycopg2_conn] __________________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn', method = 'multi' 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("method", [None, "multi"]) 2625s def test_to_sql(conn, method, test_frame1, request): 2625s if method == "multi" and "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'method' not implemented for ADBC drivers", strict=True 2625s ) 2625s ) 2625s 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______________ test_to_sql_exist[replace-1-mysql_pymysql_engine] _______________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'replace' 2625s num_row_coef = 1 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2625s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2625s conn = request.getfixturevalue(conn) 2625s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______________ test_to_sql_exist[replace-1-mysql_pymysql_conn] ________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn', mode = 'replace', num_row_coef = 1 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2625s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________ test_to_sql_exist[replace-1-postgresql_psycopg2_engine] ____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s mode = 'replace', num_row_coef = 1 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2625s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2625s conn = request.getfixturevalue(conn) 2625s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____________ test_to_sql_exist[replace-1-postgresql_psycopg2_conn] _____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn', mode = 'replace', num_row_coef = 1 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2625s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______________ test_to_sql_exist[append-2-mysql_pymysql_engine] _______________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'append' 2625s num_row_coef = 2 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2625s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2625s conn = request.getfixturevalue(conn) 2625s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ________________ test_to_sql_exist[append-2-mysql_pymysql_conn] ________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn', mode = 'append', num_row_coef = 2 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2625s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____________ test_to_sql_exist[append-2-postgresql_psycopg2_engine] ____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s mode = 'append', num_row_coef = 2 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2625s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2625s conn = request.getfixturevalue(conn) 2625s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _____________ test_to_sql_exist[append-2-postgresql_psycopg2_conn] _____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn', mode = 'append', num_row_coef = 2 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2625s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________________ test_to_sql_exist_fail[mysql_pymysql_engine] _________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_to_sql_exist_fail(conn, test_frame1, request): 2625s conn = request.getfixturevalue(conn) 2625s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __________________ test_to_sql_exist_fail[mysql_pymysql_conn] __________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_to_sql_exist_fail(conn, test_frame1, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______________ test_to_sql_exist_fail[postgresql_psycopg2_engine] ______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_to_sql_exist_fail(conn, test_frame1, request): 2625s conn = request.getfixturevalue(conn) 2625s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______________ test_to_sql_exist_fail[postgresql_psycopg2_conn] _______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_to_sql_exist_fail(conn, test_frame1, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______________ test_read_iris_query[mysql_pymysql_engine_iris] ________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_iris_query(conn, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ________________ test_read_iris_query[mysql_pymysql_conn_iris] _________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_iris_query(conn, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____________ test_read_iris_query[postgresql_psycopg2_engine_iris] _____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_iris_query(conn, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _____________ test_read_iris_query[postgresql_psycopg2_conn_iris] ______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_iris_query(conn, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __________ test_read_iris_query_chunksize[mysql_pymysql_engine_iris] ___________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_iris_query_chunksize(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'chunksize' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________ test_read_iris_query_chunksize[mysql_pymysql_conn_iris] ____________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_iris_query_chunksize(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'chunksize' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______ test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] ________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_iris_query_chunksize(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'chunksize' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________ test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_iris_query_chunksize(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'chunksize' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] ___ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2625s def test_read_iris_query_expression_with_parameter(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'chunksize' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___ test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] ____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2625s def test_read_iris_query_expression_with_parameter(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'chunksize' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2625s def test_read_iris_query_expression_with_parameter(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'chunksize' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2625s def test_read_iris_query_expression_with_parameter(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'chunksize' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_iris' 2625s request = > 2625s 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=?'}} 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'chunksize' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s 2625s for db, query in sql_strings["read_parameters"].items(): 2625s if db in conn: 2625s break 2625s else: 2625s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] ______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_iris' 2625s request = > 2625s 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=?'}} 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'chunksize' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s 2625s for db, query in sql_strings["read_parameters"].items(): 2625s if db in conn: 2625s break 2625s else: 2625s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_iris' 2625s request = > 2625s 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=?'}} 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'chunksize' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s 2625s for db, query in sql_strings["read_parameters"].items(): 2625s if db in conn: 2625s break 2625s else: 2625s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_iris' 2625s request = > 2625s 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=?'}} 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'chunksize' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s 2625s for db, query in sql_strings["read_parameters"].items(): 2625s if db in conn: 2625s break 2625s else: 2625s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______________ test_read_iris_table[mysql_pymysql_engine_iris] ________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2625s def test_read_iris_table(conn, request): 2625s # GH 51015 if conn = sqlite_iris_str 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ________________ test_read_iris_table[mysql_pymysql_conn_iris] _________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2625s def test_read_iris_table(conn, request): 2625s # GH 51015 if conn = sqlite_iris_str 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____________ test_read_iris_table[postgresql_psycopg2_engine_iris] _____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2625s def test_read_iris_table(conn, request): 2625s # GH 51015 if conn = sqlite_iris_str 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _____________ test_read_iris_table[postgresql_psycopg2_conn_iris] ______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2625s def test_read_iris_table(conn, request): 2625s # GH 51015 if conn = sqlite_iris_str 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __________ test_read_iris_table_chunksize[mysql_pymysql_engine_iris] ___________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2625s def test_read_iris_table_chunksize(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________ test_read_iris_table_chunksize[mysql_pymysql_conn_iris] ____________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2625s def test_read_iris_table_chunksize(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______ test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] ________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2625s def test_read_iris_table_chunksize(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________ test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2625s def test_read_iris_table_chunksize(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __________________ test_to_sql_callable[mysql_pymysql_engine] __________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2625s def test_to_sql_callable(conn, test_frame1, request): 2625s conn = request.getfixturevalue(conn) 2625s 2625s check = [] # used to double check function below is really being used 2625s 2625s def sample(pd_table, conn, keys, data_iter): 2625s check.append(1) 2625s data = [dict(zip(keys, row)) for row in data_iter] 2625s conn.execute(pd_table.table.insert(), data) 2625s 2625s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________________ test_to_sql_callable[mysql_pymysql_conn] ___________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2625s def test_to_sql_callable(conn, test_frame1, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______________ test_to_sql_callable[postgresql_psycopg2_engine] _______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2625s def test_to_sql_callable(conn, test_frame1, request): 2625s conn = request.getfixturevalue(conn) 2625s 2625s check = [] # used to double check function below is really being used 2625s 2625s def sample(pd_table, conn, keys, data_iter): 2625s check.append(1) 2625s data = [dict(zip(keys, row)) for row in data_iter] 2625s conn.execute(pd_table.table.insert(), data) 2625s 2625s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________________ test_to_sql_callable[postgresql_psycopg2_conn] ________________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2625s def test_to_sql_callable(conn, test_frame1, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___________ test_default_type_conversion[mysql_pymysql_engine_types] ___________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_types' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s def test_default_type_conversion(conn, request): 2625s conn_name = conn 2625s if conn_name == "sqlite_buildin_types": 2625s request.applymarker( 2625s pytest.mark.xfail( 2625s reason="sqlite_buildin connection does not implement read_sql_table" 2625s ) 2625s ) 2625s 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2625s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____________ test_default_type_conversion[mysql_pymysql_conn_types] ____________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_types' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s def test_default_type_conversion(conn, request): 2625s conn_name = conn 2625s if conn_name == "sqlite_buildin_types": 2625s request.applymarker( 2625s pytest.mark.xfail( 2625s reason="sqlite_buildin connection does not implement read_sql_table" 2625s ) 2625s ) 2625s 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2625s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ________ test_default_type_conversion[postgresql_psycopg2_engine_types] ________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_types' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s def test_default_type_conversion(conn, request): 2625s conn_name = conn 2625s if conn_name == "sqlite_buildin_types": 2625s request.applymarker( 2625s pytest.mark.xfail( 2625s reason="sqlite_buildin connection does not implement read_sql_table" 2625s ) 2625s ) 2625s 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2625s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________ test_default_type_conversion[postgresql_psycopg2_conn_types] _________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_types' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s def test_default_type_conversion(conn, request): 2625s conn_name = conn 2625s if conn_name == "sqlite_buildin_types": 2625s request.applymarker( 2625s pytest.mark.xfail( 2625s reason="sqlite_buildin connection does not implement read_sql_table" 2625s ) 2625s ) 2625s 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2625s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __________________ test_read_procedure[mysql_pymysql_engine] ___________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", mysql_connectable) 2625s def test_read_procedure(conn, request): 2625s conn = request.getfixturevalue(conn) 2625s 2625s # GH 7324 2625s # Although it is more an api test, it is added to the 2625s # mysql tests as sqlite does not have stored procedures 2625s from sqlalchemy import text 2625s from sqlalchemy.engine import Engine 2625s 2625s df = DataFrame({"a": [1, 2, 3], "b": [0.1, 0.2, 0.3]}) 2625s > df.to_sql(name="test_frame", con=conn, index=False) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1253: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2625s return func(*args, **kwargs) 2625s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2625s return sql.to_sql( 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2625s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________________ test_read_procedure[mysql_pymysql_conn] ____________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", mysql_connectable) 2625s def test_read_procedure(conn, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1244: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] ____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s expected_count = 2 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", postgresql_connectable) 2625s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2625s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2625s # GH 8953 2625s # Example in io.rst found under _io.sql.method 2625s # not available in sqlite, mysql 2625s def psql_insert_copy(table, conn, keys, data_iter): 2625s # gets a DBAPI connection that can provide a cursor 2625s dbapi_conn = conn.connection 2625s with dbapi_conn.cursor() as cur: 2625s s_buf = StringIO() 2625s writer = csv.writer(s_buf) 2625s writer.writerows(data_iter) 2625s s_buf.seek(0) 2625s 2625s columns = ", ".join([f'"{k}"' for k in keys]) 2625s if table.schema: 2625s table_name = f"{table.schema}.{table.name}" 2625s else: 2625s table_name = table.name 2625s 2625s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2625s cur.copy_expert(sql=sql_query, file=s_buf) 2625s return expected_count 2625s 2625s conn = request.getfixturevalue(conn) 2625s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 2625s > result_count = expected.to_sql( 2625s name="test_frame", con=conn, index=False, method=psql_insert_copy 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2625s return func(*args, **kwargs) 2625s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2625s return sql.to_sql( 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2625s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn', expected_count = 2 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", postgresql_connectable) 2625s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2625s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2625s # GH 8953 2625s # Example in io.rst found under _io.sql.method 2625s # not available in sqlite, mysql 2625s def psql_insert_copy(table, conn, keys, data_iter): 2625s # gets a DBAPI connection that can provide a cursor 2625s dbapi_conn = conn.connection 2625s with dbapi_conn.cursor() as cur: 2625s s_buf = StringIO() 2625s writer = csv.writer(s_buf) 2625s writer.writerows(data_iter) 2625s s_buf.seek(0) 2625s 2625s columns = ", ".join([f'"{k}"' for k in keys]) 2625s if table.schema: 2625s table_name = f"{table.schema}.{table.name}" 2625s else: 2625s table_name = table.name 2625s 2625s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2625s cur.copy_expert(sql=sql_query, file=s_buf) 2625s return expected_count 2625s 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s expected_count = 'Success!' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", postgresql_connectable) 2625s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2625s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2625s # GH 8953 2625s # Example in io.rst found under _io.sql.method 2625s # not available in sqlite, mysql 2625s def psql_insert_copy(table, conn, keys, data_iter): 2625s # gets a DBAPI connection that can provide a cursor 2625s dbapi_conn = conn.connection 2625s with dbapi_conn.cursor() as cur: 2625s s_buf = StringIO() 2625s writer = csv.writer(s_buf) 2625s writer.writerows(data_iter) 2625s s_buf.seek(0) 2625s 2625s columns = ", ".join([f'"{k}"' for k in keys]) 2625s if table.schema: 2625s table_name = f"{table.schema}.{table.name}" 2625s else: 2625s table_name = table.name 2625s 2625s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2625s cur.copy_expert(sql=sql_query, file=s_buf) 2625s return expected_count 2625s 2625s conn = request.getfixturevalue(conn) 2625s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 2625s > result_count = expected.to_sql( 2625s name="test_frame", con=conn, index=False, method=psql_insert_copy 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2625s return func(*args, **kwargs) 2625s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2625s return sql.to_sql( 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2625s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn', expected_count = 'Success!' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", postgresql_connectable) 2625s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2625s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2625s # GH 8953 2625s # Example in io.rst found under _io.sql.method 2625s # not available in sqlite, mysql 2625s def psql_insert_copy(table, conn, keys, data_iter): 2625s # gets a DBAPI connection that can provide a cursor 2625s dbapi_conn = conn.connection 2625s with dbapi_conn.cursor() as cur: 2625s s_buf = StringIO() 2625s writer = csv.writer(s_buf) 2625s writer.writerows(data_iter) 2625s s_buf.seek(0) 2625s 2625s columns = ", ".join([f'"{k}"' for k in keys]) 2625s if table.schema: 2625s table_name = f"{table.schema}.{table.name}" 2625s else: 2625s table_name = table.name 2625s 2625s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2625s cur.copy_expert(sql=sql_query, file=s_buf) 2625s return expected_count 2625s 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", postgresql_connectable) 2625s def test_insertion_method_on_conflict_do_nothing(conn, request): 2625s # GH 15988: Example in to_sql docstring 2625s conn = request.getfixturevalue(conn) 2625s 2625s from sqlalchemy.dialects.postgresql import insert 2625s from sqlalchemy.engine import Engine 2625s from sqlalchemy.sql import text 2625s 2625s def insert_on_conflict(table, conn, keys, data_iter): 2625s data = [dict(zip(keys, row)) for row in data_iter] 2625s stmt = ( 2625s insert(table.table) 2625s .values(data) 2625s .on_conflict_do_nothing(index_elements=["a"]) 2625s ) 2625s result = conn.execute(stmt) 2625s return result.rowcount 2625s 2625s create_sql = text( 2625s """ 2625s CREATE TABLE test_insert_conflict ( 2625s a integer PRIMARY KEY, 2625s b numeric, 2625s c text 2625s ); 2625s """ 2625s ) 2625s if isinstance(conn, Engine): 2625s > with conn.connect() as con: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1347: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] ____ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", postgresql_connectable) 2625s def test_insertion_method_on_conflict_do_nothing(conn, request): 2625s # GH 15988: Example in to_sql docstring 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1321: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___________ test_to_sql_on_public_schema[postgresql_psycopg2_engine] ___________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_to_sql_on_public_schema(conn, request): 2625s if "sqlite" in conn or "mysql" in conn: 2625s request.applymarker( 2625s pytest.mark.xfail( 2625s reason="test for public schema only specific to postgresql" 2625s ) 2625s ) 2625s 2625s conn = request.getfixturevalue(conn) 2625s 2625s test_data = DataFrame([[1, 2.1, "a"], [2, 3.1, "b"]], columns=list("abc")) 2625s > test_data.to_sql( 2625s name="test_public_schema", 2625s con=conn, 2625s if_exists="append", 2625s index=False, 2625s schema="public", 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1388: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2625s return func(*args, **kwargs) 2625s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2625s return sql.to_sql( 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2625s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____________ test_to_sql_on_public_schema[postgresql_psycopg2_conn] ____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_to_sql_on_public_schema(conn, request): 2625s if "sqlite" in conn or "mysql" in conn: 2625s request.applymarker( 2625s pytest.mark.xfail( 2625s reason="test for public schema only specific to postgresql" 2625s ) 2625s ) 2625s 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1385: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________ test_insertion_method_on_conflict_update[mysql_pymysql_engine] ________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", mysql_connectable) 2625s def test_insertion_method_on_conflict_update(conn, request): 2625s # GH 14553: Example in to_sql docstring 2625s conn = request.getfixturevalue(conn) 2625s 2625s from sqlalchemy.dialects.mysql import insert 2625s from sqlalchemy.engine import Engine 2625s from sqlalchemy.sql import text 2625s 2625s def insert_on_conflict(table, conn, keys, data_iter): 2625s data = [dict(zip(keys, row)) for row in data_iter] 2625s stmt = insert(table.table).values(data) 2625s stmt = stmt.on_duplicate_key_update(b=stmt.inserted.b, c=stmt.inserted.c) 2625s result = conn.execute(stmt) 2625s return result.rowcount 2625s 2625s create_sql = text( 2625s """ 2625s CREATE TABLE test_insert_conflict ( 2625s a INT PRIMARY KEY, 2625s b FLOAT, 2625s c VARCHAR(10) 2625s ); 2625s """ 2625s ) 2625s if isinstance(conn, Engine): 2625s > with conn.connect() as con: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1426: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _________ test_insertion_method_on_conflict_update[mysql_pymysql_conn] _________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", mysql_connectable) 2625s def test_insertion_method_on_conflict_update(conn, request): 2625s # GH 14553: Example in to_sql docstring 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1403: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____________ test_read_view_postgres[postgresql_psycopg2_engine] ______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", postgresql_connectable) 2625s def test_read_view_postgres(conn, request): 2625s # GH 52969 2625s conn = request.getfixturevalue(conn) 2625s 2625s from sqlalchemy.engine import Engine 2625s from sqlalchemy.sql import text 2625s 2625s table_name = f"group_{uuid.uuid4().hex}" 2625s view_name = f"group_view_{uuid.uuid4().hex}" 2625s 2625s sql_stmt = text( 2625s f""" 2625s CREATE TABLE {table_name} ( 2625s group_id INTEGER, 2625s name TEXT 2625s ); 2625s INSERT INTO {table_name} VALUES 2625s (1, 'name'); 2625s CREATE VIEW {view_name} 2625s AS 2625s SELECT * FROM {table_name}; 2625s """ 2625s ) 2625s if isinstance(conn, Engine): 2625s > with conn.connect() as con: 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1478: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______________ test_read_view_postgres[postgresql_psycopg2_conn] _______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", postgresql_connectable) 2625s def test_read_view_postgres(conn, request): 2625s # GH 52969 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1456: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___________ test_read_sql_iris_parameter[mysql_pymysql_engine_iris] ____________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_iris' 2625s request = > 2625s 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=?'}} 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_sql_iris_parameter(conn, request, sql_strings): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'params' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____________ test_read_sql_iris_parameter[mysql_pymysql_conn_iris] _____________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_iris' 2625s request = > 2625s 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=?'}} 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_sql_iris_parameter(conn, request, sql_strings): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'params' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ________ test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_iris' 2625s request = > 2625s 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=?'}} 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_sql_iris_parameter(conn, request, sql_strings): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'params' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________ test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] __________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_iris' 2625s request = > 2625s 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=?'}} 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_sql_iris_parameter(conn, request, sql_strings): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'params' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________ test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_iris' 2625s request = > 2625s 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=?'}} 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'params' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _________ test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] __________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_iris' 2625s request = > 2625s 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=?'}} 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'params' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] ______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_iris' 2625s request = > 2625s 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=?'}} 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'params' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______ test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _______ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_iris' 2625s request = > 2625s 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=?'}} 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail( 2625s reason="'params' not implemented for ADBC drivers", 2625s strict=True, 2625s ) 2625s ) 2625s 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______________ test_api_read_sql_view[mysql_pymysql_engine_iris] _______________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_api_read_sql_view(conn, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______________ test_api_read_sql_view[mysql_pymysql_conn_iris] ________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_api_read_sql_view(conn, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________ test_api_read_sql_view[postgresql_psycopg2_engine_iris] ____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_api_read_sql_view(conn, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____________ test_api_read_sql_view[postgresql_psycopg2_conn_iris] _____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_api_read_sql_view(conn, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _____ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_api_read_sql_with_chunksize_no_result(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] ______ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_api_read_sql_with_chunksize_no_result(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] __ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_api_read_sql_with_chunksize_no_result(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] ___ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_api_read_sql_with_chunksize_no_result(conn, request): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____________________ test_api_to_sql[mysql_pymysql_engine] _____________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql(conn, request, test_frame1): 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame1", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____________________ test_api_to_sql[mysql_pymysql_conn] ______________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql(conn, request, test_frame1): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _________________ test_api_to_sql[postgresql_psycopg2_engine] __________________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql(conn, request, test_frame1): 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame1", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __________________ test_api_to_sql[postgresql_psycopg2_conn] ___________________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql(conn, request, test_frame1): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s __________________ test_api_to_sql_fail[mysql_pymysql_engine] __________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_fail(conn, request, test_frame1): 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame2", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________________ test_api_to_sql_fail[mysql_pymysql_conn] ___________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_fail(conn, request, test_frame1): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______________ test_api_to_sql_fail[postgresql_psycopg2_engine] _______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_fail(conn, request, test_frame1): 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame2", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________________ test_api_to_sql_fail[postgresql_psycopg2_conn] ________________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_fail(conn, request, test_frame1): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ________________ test_api_to_sql_replace[mysql_pymysql_engine] _________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_replace(conn, request, test_frame1): 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame3", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _________________ test_api_to_sql_replace[mysql_pymysql_conn] __________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_replace(conn, request, test_frame1): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _____________ test_api_to_sql_replace[postgresql_psycopg2_engine] ______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_replace(conn, request, test_frame1): 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame3", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______________ test_api_to_sql_replace[postgresql_psycopg2_conn] _______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_replace(conn, request, test_frame1): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________________ test_api_to_sql_append[mysql_pymysql_engine] _________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_append(conn, request, test_frame1): 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame4", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __________________ test_api_to_sql_append[mysql_pymysql_conn] __________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_append(conn, request, test_frame1): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______________ test_api_to_sql_append[postgresql_psycopg2_engine] ______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_append(conn, request, test_frame1): 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame4", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______________ test_api_to_sql_append[postgresql_psycopg2_conn] _______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_append(conn, request, test_frame1): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______________ test_api_to_sql_type_mapping[mysql_pymysql_engine] ______________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s request = > 2625s test_frame3 = index A B 2625s 0 2000-01-03 00:00:00 2147483647 -1.987670 2625s 1 2000-01-04 00:00:00 -29 -0.041232 2625s 2 2000-01-05 00:00:00 20000 0.731168 2625s 3 2000-01-06 00:00:00 -290867 1.567621 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame5", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______________ test_api_to_sql_type_mapping[mysql_pymysql_conn] _______________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s request = > 2625s test_frame3 = index A B 2625s 0 2000-01-03 00:00:00 2147483647 -1.987670 2625s 1 2000-01-04 00:00:00 -29 -0.041232 2625s 2 2000-01-05 00:00:00 20000 0.731168 2625s 3 2000-01-06 00:00:00 -290867 1.567621 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________ test_api_to_sql_type_mapping[postgresql_psycopg2_engine] ___________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s request = > 2625s test_frame3 = index A B 2625s 0 2000-01-03 00:00:00 2147483647 -1.987670 2625s 1 2000-01-04 00:00:00 -29 -0.041232 2625s 2 2000-01-05 00:00:00 20000 0.731168 2625s 3 2000-01-06 00:00:00 -290867 1.567621 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame5", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____________ test_api_to_sql_type_mapping[postgresql_psycopg2_conn] ____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s request = > 2625s test_frame3 = index A B 2625s 0 2000-01-03 00:00:00 2147483647 -1.987670 2625s 1 2000-01-04 00:00:00 -29 -0.041232 2625s 2 2000-01-05 00:00:00 20000 0.731168 2625s 3 2000-01-06 00:00:00 -290867 1.567621 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________________ test_api_to_sql_series[mysql_pymysql_engine] _________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_series(conn, request): 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_series", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s __________________ test_api_to_sql_series[mysql_pymysql_conn] __________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_series(conn, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ______________ test_api_to_sql_series[postgresql_psycopg2_engine] ______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_series(conn, request): 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_series", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______________ test_api_to_sql_series[postgresql_psycopg2_conn] _______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_to_sql_series(conn, request): 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ___________________ test_api_roundtrip[mysql_pymysql_engine] ___________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_roundtrip(conn, request, test_frame1): 2625s conn_name = conn 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame_roundtrip", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____________________ test_api_roundtrip[mysql_pymysql_conn] ____________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_roundtrip(conn, request, test_frame1): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ________________ test_api_roundtrip[postgresql_psycopg2_engine] ________________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_roundtrip(conn, request, test_frame1): 2625s conn_name = conn 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame_roundtrip", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _________________ test_api_roundtrip[postgresql_psycopg2_conn] _________________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_roundtrip(conn, request, test_frame1): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______________ test_api_roundtrip_chunksize[mysql_pymysql_engine] ______________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2625s ) 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame_roundtrip", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______________ test_api_roundtrip_chunksize[mysql_pymysql_conn] _______________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn' 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2625s with mysql_pymysql_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________ test_api_roundtrip_chunksize[postgresql_psycopg2_engine] ___________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2625s ) 2625s conn = request.getfixturevalue(conn) 2625s > if sql.has_table("test_frame_roundtrip", conn): 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2625s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2625s return SQLDatabase(con, schema, need_transaction) 2625s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2625s con = self.exit_stack.enter_context(con.connect()) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____________ test_api_roundtrip_chunksize[postgresql_psycopg2_conn] ____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn' 2625s request = > 2625s test_frame1 = index A B C D 2625s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2625s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2625s 2625s @pytest.mark.parametrize("conn", all_connectable) 2625s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2625s if "adbc" in conn: 2625s request.node.add_marker( 2625s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2625s ) 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2625s with postgresql_psycopg2_engine.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _______________ test_api_execute_sql[mysql_pymysql_engine_iris] ________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_api_execute_sql(conn, request): 2625s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ________________ test_api_execute_sql[mysql_pymysql_conn_iris] _________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_api_execute_sql(conn, request): 2625s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2625s create_and_load_iris(mysql_pymysql_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ____________ test_api_execute_sql[postgresql_psycopg2_engine_iris] _____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_api_execute_sql(conn, request): 2625s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _____________ test_api_execute_sql[postgresql_psycopg2_conn_iris] ______________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_iris' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_iris) 2625s def test_api_execute_sql(conn, request): 2625s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2625s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2625s with conn.begin() as con: 2625s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2625s return next(self.gen) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2625s with self.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ______________ test_api_date_parsing[mysql_pymysql_engine_types] _______________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_types' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s def test_api_date_parsing(conn, request): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2625s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _______________ test_api_date_parsing[mysql_pymysql_conn_types] ________________ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_types' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s def test_api_date_parsing(conn, request): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2625s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s ___________ test_api_date_parsing[postgresql_psycopg2_engine_types] ____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_types' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s def test_api_date_parsing(conn, request): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2625s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s ____________ test_api_date_parsing[postgresql_psycopg2_conn_types] _____________ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_types' 2625s request = > 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s def test_api_date_parsing(conn, request): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2625s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_types' 2625s request = > 2625s read_sql = , text = 'SELECT * FROM types' 2625s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2625s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2625s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2625s 1 first 2000-01-04 00:00:00 ... NaN NaN 2625s 2625s [2 rows x 9 columns] 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2625s @pytest.mark.parametrize( 2625s "read_sql, text, mode", 2625s [ 2625s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2625s (sql.read_sql, "types", ("sqlalchemy")), 2625s ( 2625s sql.read_sql_query, 2625s "SELECT * FROM types", 2625s ("sqlalchemy", "fallback"), 2625s ), 2625s (sql.read_sql_table, "types", ("sqlalchemy")), 2625s ], 2625s ) 2625s def test_api_custom_dateparsing_error( 2625s conn, request, read_sql, text, mode, error, types_data_frame 2625s ): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2625s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_types' 2625s request = > 2625s read_sql = , text = 'SELECT * FROM types' 2625s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2625s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2625s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2625s 1 first 2000-01-04 00:00:00 ... NaN NaN 2625s 2625s [2 rows x 9 columns] 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2625s @pytest.mark.parametrize( 2625s "read_sql, text, mode", 2625s [ 2625s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2625s (sql.read_sql, "types", ("sqlalchemy")), 2625s ( 2625s sql.read_sql_query, 2625s "SELECT * FROM types", 2625s ("sqlalchemy", "fallback"), 2625s ), 2625s (sql.read_sql_table, "types", ("sqlalchemy")), 2625s ], 2625s ) 2625s def test_api_custom_dateparsing_error( 2625s conn, request, read_sql, text, mode, error, types_data_frame 2625s ): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2625s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_types' 2625s request = > 2625s read_sql = , text = 'SELECT * FROM types' 2625s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2625s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2625s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2625s 1 first 2000-01-04 00:00:00 ... NaN NaN 2625s 2625s [2 rows x 9 columns] 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2625s @pytest.mark.parametrize( 2625s "read_sql, text, mode", 2625s [ 2625s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2625s (sql.read_sql, "types", ("sqlalchemy")), 2625s ( 2625s sql.read_sql_query, 2625s "SELECT * FROM types", 2625s ("sqlalchemy", "fallback"), 2625s ), 2625s (sql.read_sql_table, "types", ("sqlalchemy")), 2625s ], 2625s ) 2625s def test_api_custom_dateparsing_error( 2625s conn, request, read_sql, text, mode, error, types_data_frame 2625s ): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2625s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_types' 2625s request = > 2625s read_sql = , text = 'SELECT * FROM types' 2625s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2625s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2625s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2625s 1 first 2000-01-04 00:00:00 ... NaN NaN 2625s 2625s [2 rows x 9 columns] 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2625s @pytest.mark.parametrize( 2625s "read_sql, text, mode", 2625s [ 2625s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2625s (sql.read_sql, "types", ("sqlalchemy")), 2625s ( 2625s sql.read_sql_query, 2625s "SELECT * FROM types", 2625s ("sqlalchemy", "fallback"), 2625s ), 2625s (sql.read_sql_table, "types", ("sqlalchemy")), 2625s ], 2625s ) 2625s def test_api_custom_dateparsing_error( 2625s conn, request, read_sql, text, mode, error, types_data_frame 2625s ): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2625s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_types' 2625s request = > 2625s read_sql = , text = 'SELECT * FROM types' 2625s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2625s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2625s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2625s 1 first 2000-01-04 00:00:00 ... NaN NaN 2625s 2625s [2 rows x 9 columns] 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2625s @pytest.mark.parametrize( 2625s "read_sql, text, mode", 2625s [ 2625s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2625s (sql.read_sql, "types", ("sqlalchemy")), 2625s ( 2625s sql.read_sql_query, 2625s "SELECT * FROM types", 2625s ("sqlalchemy", "fallback"), 2625s ), 2625s (sql.read_sql_table, "types", ("sqlalchemy")), 2625s ], 2625s ) 2625s def test_api_custom_dateparsing_error( 2625s conn, request, read_sql, text, mode, error, types_data_frame 2625s ): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2625s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_types' 2625s request = > 2625s read_sql = , text = 'SELECT * FROM types' 2625s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2625s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2625s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2625s 1 first 2000-01-04 00:00:00 ... NaN NaN 2625s 2625s [2 rows x 9 columns] 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2625s @pytest.mark.parametrize( 2625s "read_sql, text, mode", 2625s [ 2625s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2625s (sql.read_sql, "types", ("sqlalchemy")), 2625s ( 2625s sql.read_sql_query, 2625s "SELECT * FROM types", 2625s ("sqlalchemy", "fallback"), 2625s ), 2625s (sql.read_sql_table, "types", ("sqlalchemy")), 2625s ], 2625s ) 2625s def test_api_custom_dateparsing_error( 2625s conn, request, read_sql, text, mode, error, types_data_frame 2625s ): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2625s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_engine_types' 2625s request = > 2625s read_sql = , text = 'SELECT * FROM types' 2625s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2625s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2625s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2625s 1 first 2000-01-04 00:00:00 ... NaN NaN 2625s 2625s [2 rows x 9 columns] 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2625s @pytest.mark.parametrize( 2625s "read_sql, text, mode", 2625s [ 2625s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2625s (sql.read_sql, "types", ("sqlalchemy")), 2625s ( 2625s sql.read_sql_query, 2625s "SELECT * FROM types", 2625s ("sqlalchemy", "fallback"), 2625s ), 2625s (sql.read_sql_table, "types", ("sqlalchemy")), 2625s ], 2625s ) 2625s def test_api_custom_dateparsing_error( 2625s conn, request, read_sql, text, mode, error, types_data_frame 2625s ): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2625s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 2625s self = 2625s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2625s connection = None, _has_events = None, _allow_revalidate = True 2625s _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'postgresql_psycopg2_conn_types' 2625s request = > 2625s read_sql = , text = 'SELECT * FROM types' 2625s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2625s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2625s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2625s 1 first 2000-01-04 00:00:00 ... NaN NaN 2625s 2625s [2 rows x 9 columns] 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2625s @pytest.mark.parametrize( 2625s "read_sql, text, mode", 2625s [ 2625s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2625s (sql.read_sql, "types", ("sqlalchemy")), 2625s ( 2625s sql.read_sql_query, 2625s "SELECT * FROM types", 2625s ("sqlalchemy", "fallback"), 2625s ), 2625s (sql.read_sql_table, "types", ("sqlalchemy")), 2625s ], 2625s ) 2625s def test_api_custom_dateparsing_error( 2625s conn, request, read_sql, text, mode, error, types_data_frame 2625s ): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2625s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2625s connection_factory = None, cursor_factory = None 2625s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2625s kwasync = {} 2625s 2625s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2625s """ 2625s Create a new database connection. 2625s 2625s The connection parameters can be specified as a string: 2625s 2625s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2625s 2625s or using a set of keyword arguments: 2625s 2625s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2625s 2625s Or as a mix of both. The basic connection parameters are: 2625s 2625s - *dbname*: the database name 2625s - *database*: the database name (only as keyword argument) 2625s - *user*: user name used to authenticate 2625s - *password*: password used to authenticate 2625s - *host*: database host address (defaults to UNIX socket if not provided) 2625s - *port*: connection port number (defaults to 5432 if not provided) 2625s 2625s Using the *connection_factory* parameter a different class or connections 2625s factory can be specified. It should be a callable object taking a dsn 2625s argument. 2625s 2625s Using the *cursor_factory* parameter, a new default cursor factory will be 2625s used by cursor(). 2625s 2625s Using *async*=True an asynchronous connection will be created. *async_* is 2625s a valid alias (for Python versions where ``async`` is a keyword). 2625s 2625s Any other keyword parameter will be passed to the underlying client 2625s library: the list of supported parameters depends on the library version. 2625s 2625s """ 2625s kwasync = {} 2625s if 'async' in kwargs: 2625s kwasync['async'] = kwargs.pop('async') 2625s if 'async_' in kwargs: 2625s kwasync['async_'] = kwargs.pop('async_') 2625s 2625s dsn = _ext.make_dsn(dsn, **kwargs) 2625s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2625s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2625s E Is the server running on that host and accepting TCP/IP connections? 2625s E 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2625s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_engine_types' 2625s request = > 2625s read_sql = , text = 'SELECT * FROM types' 2625s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2625s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2625s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2625s 1 first 2000-01-04 00:00:00 ... NaN NaN 2625s 2625s [2 rows x 9 columns] 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2625s @pytest.mark.parametrize( 2625s "read_sql, text, mode", 2625s [ 2625s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2625s (sql.read_sql, "types", ("sqlalchemy")), 2625s ( 2625s sql.read_sql_query, 2625s "SELECT * FROM types", 2625s ("sqlalchemy", "fallback"), 2625s ), 2625s (sql.read_sql_table, "types", ("sqlalchemy")), 2625s ], 2625s ) 2625s def test_api_custom_dateparsing_error( 2625s conn, request, read_sql, text, mode, error, types_data_frame 2625s ): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2625s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s > sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3.13/socket.py:864: in create_connection 2625s raise exceptions[0] 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s address = ('localhost', 3306), timeout = 10, source_address = None 2625s 2625s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2625s source_address=None, *, all_errors=False): 2625s """Connect to *address* and return the socket object. 2625s 2625s Convenience function. Connect to *address* (a 2-tuple ``(host, 2625s port)``) and return the socket object. Passing the optional 2625s *timeout* parameter will set the timeout on the socket instance 2625s before attempting to connect. If no *timeout* is supplied, the 2625s global default timeout setting returned by :func:`getdefaulttimeout` 2625s is used. If *source_address* is set it must be a tuple of (host, port) 2625s for the socket to bind as a source address before making the connection. 2625s A host of '' or port 0 tells the OS to use the default. When a connection 2625s cannot be created, raises the last error if *all_errors* is False, 2625s and an ExceptionGroup of all errors if *all_errors* is True. 2625s """ 2625s 2625s host, port = address 2625s exceptions = [] 2625s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2625s af, socktype, proto, canonname, sa = res 2625s sock = None 2625s try: 2625s sock = socket(af, socktype, proto) 2625s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2625s sock.settimeout(timeout) 2625s if source_address: 2625s sock.bind(source_address) 2625s > sock.connect(sa) 2625s E ConnectionRefusedError: [Errno 111] Connection refused 2625s 2625s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2625s 2625s During handling of the above exception, another exception occurred: 2625s 2625s self = 2625s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2625s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2625s 2625s def __init__( 2625s self, 2625s engine: Engine, 2625s connection: Optional[PoolProxiedConnection] = None, 2625s _has_events: Optional[bool] = None, 2625s _allow_revalidate: bool = True, 2625s _allow_autobegin: bool = True, 2625s ): 2625s """Construct a new Connection.""" 2625s self.engine = engine 2625s self.dialect = dialect = engine.dialect 2625s 2625s if connection is None: 2625s try: 2625s > self._dbapi_connection = engine.raw_connection() 2625s 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2625s if isinstance(e, (OSError, IOError)): 2625s exc = err.OperationalError( 2625s CR.CR_CONN_HOST_ERROR, 2625s f"Can't connect to MySQL server on {self.host!r} ({e})", 2625s ) 2625s # Keep original exception and traceback to investigate error. 2625s exc.original_exception = e 2625s exc.traceback = traceback.format_exc() 2625s if DEBUG: 2625s print(exc.traceback) 2625s > raise exc 2625s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2625s 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2625s 2625s The above exception was the direct cause of the following exception: 2625s 2625s conn = 'mysql_pymysql_conn_types' 2625s request = > 2625s read_sql = , text = 'SELECT * FROM types' 2625s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2625s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2625s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2625s 1 first 2000-01-04 00:00:00 ... NaN NaN 2625s 2625s [2 rows x 9 columns] 2625s 2625s @pytest.mark.parametrize("conn", all_connectable_types) 2625s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2625s @pytest.mark.parametrize( 2625s "read_sql, text, mode", 2625s [ 2625s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2625s (sql.read_sql, "types", ("sqlalchemy")), 2625s ( 2625s sql.read_sql_query, 2625s "SELECT * FROM types", 2625s ("sqlalchemy", "fallback"), 2625s ), 2625s (sql.read_sql_table, "types", ("sqlalchemy")), 2625s ], 2625s ) 2625s def test_api_custom_dateparsing_error( 2625s conn, request, read_sql, text, mode, error, types_data_frame 2625s ): 2625s conn_name = conn 2625s > conn = request.getfixturevalue(conn) 2625s 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2625s fixturedef = self._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2625s fixturedef = request._get_active_fixturedef(argname) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2625s fixturedef.execute(request=subrequest) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2625s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2625s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2625s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2625s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2625s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2625s return (yield) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2625s result = call_fixture_func(fixturefunc, request, kwargs) 2625s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2625s fixture_result = next(generator) 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2625s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2625s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2625s with conn.connect() as conn: 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2625s return self._connection_cls(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2625s Connection._handle_dbapi_exception_noconnection( 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2625s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2625s self._dbapi_connection = engine.raw_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2625s return self.pool.connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2625s return _ConnectionFairy._checkout(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2625s fairy = _ConnectionRecord.checkout(pool) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2625s rec = pool._do_get() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2625s return self._create_connection() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2625s return _ConnectionRecord(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2625s self.__connect() 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2625s with util.safe_reraise(): 2625s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2625s raise exc_value.with_traceback(exc_tb) 2625s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2625s self.dbapi_connection = connection = pool._invoke_creator(self) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2625s return dialect.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2625s return self.loaded_dbapi.connect(*cargs, **cparams) 2625s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2625s self.connect() 2625s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2625s 2625s self = , sock = None 2625s 2625s def connect(self, sock=None): 2625s self._closed = False 2625s try: 2625s if sock is None: 2625s if self.unix_socket: 2625s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2625s sock.settimeout(self.connect_timeout) 2625s sock.connect(self.unix_socket) 2625s self.host_info = "Localhost via UNIX socket" 2625s self._secure = True 2625s if DEBUG: 2625s print("connected using unix_socket") 2625s else: 2625s kwargs = {} 2625s if self.bind_address is not None: 2625s kwargs["source_address"] = (self.bind_address, 0) 2625s while True: 2625s try: 2625s sock = socket.create_connection( 2625s (self.host, self.port), self.connect_timeout, **kwargs 2625s ) 2625s break 2625s except OSError as e: 2625s if e.errno == errno.EINTR: 2625s continue 2625s raise 2625s self.host_info = "socket %s:%d" % (self.host, self.port) 2625s if DEBUG: 2625s print("connected using socket") 2625s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2625s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2625s sock.settimeout(None) 2625s 2625s self._sock = sock 2625s self._rfile = sock.makefile("rb") 2625s self._next_seq_id = 0 2625s 2625s self._get_server_information() 2625s self._request_authentication() 2625s 2625s # Send "SET NAMES" query on init for: 2625s # - Ensure charaset (and collation) is set to the server. 2625s # - collation_id in handshake packet may be ignored. 2625s # - If collation is not specified, we don't know what is server's 2625s # default collation for the charset. For example, default collation 2625s # of utf8mb4 is: 2625s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2625s # - MySQL 8.0: utf8mb4_0900_ai_ci 2625s # 2625s # Reference: 2625s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2625s # - https://github.com/wagtail/wagtail/issues/9477 2625s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2625s self.set_character_set(self.charset, self.collation) 2625s 2625s if self.sql_mode is not None: 2625s c = self.cursor() 2625s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2625s c.close() 2625s 2625s if self.init_command is not None: 2625s c = self.cursor() 2625s c.execute(self.init_command) 2625s c.close() 2625s 2625s if self.autocommit_mode is not None: 2625s self.autocommit(self.autocommit_mode) 2625s except BaseException as e: 2625s self._rfile = None 2625s if sock is not None: 2625s try: 2625s sock.close() 2625s except: # noqa 2625s pass 2625s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s read_sql = , text = 'SELECT * FROM types' 2626s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s read_sql = , text = 'SELECT * FROM types' 2626s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'ignore' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'ignore' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'ignore' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'ignore' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'raise' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'raise' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'raise' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'raise' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_types' 2626s request = > 2626s read_sql = 2626s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2626s error = 'ignore' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_types' 2626s request = > 2626s read_sql = 2626s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2626s error = 'ignore' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s read_sql = 2626s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2626s error = 'ignore' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s read_sql = 2626s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2626s error = 'ignore' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_types' 2626s request = > 2626s read_sql = 2626s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_types' 2626s request = > 2626s read_sql = 2626s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s read_sql = 2626s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s read_sql = 2626s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_types' 2626s request = > 2626s read_sql = 2626s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2626s error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_types' 2626s request = > 2626s read_sql = 2626s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2626s error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s read_sql = 2626s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2626s error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s read_sql = 2626s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2626s error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'ignore' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'ignore' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'ignore' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'ignore' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'raise' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'raise' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'raise' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'raise' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s read_sql = , text = 'types' 2626s mode = 'sqlalchemy', error = 'coerce' 2626s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2626s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2626s 1 first 2000-01-04 00:00:00 ... NaN NaN 2626s 2626s [2 rows x 9 columns] 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2626s @pytest.mark.parametrize( 2626s "read_sql, text, mode", 2626s [ 2626s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2626s (sql.read_sql, "types", ("sqlalchemy")), 2626s ( 2626s sql.read_sql_query, 2626s "SELECT * FROM types", 2626s ("sqlalchemy", "fallback"), 2626s ), 2626s (sql.read_sql_table, "types", ("sqlalchemy")), 2626s ], 2626s ) 2626s def test_api_custom_dateparsing_error( 2626s conn, request, read_sql, text, mode, error, types_data_frame 2626s ): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____________ test_api_date_and_index[mysql_pymysql_engine_types] ______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s def test_api_date_and_index(conn, request): 2626s # Test case where same column appears in parse_date and index_col 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______________ test_api_date_and_index[mysql_pymysql_conn_types] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s def test_api_date_and_index(conn, request): 2626s # Test case where same column appears in parse_date and index_col 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________ test_api_date_and_index[postgresql_psycopg2_engine_types] ___________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s def test_api_date_and_index(conn, request): 2626s # Test case where same column appears in parse_date and index_col 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________ test_api_date_and_index[postgresql_psycopg2_conn_types] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_types) 2626s def test_api_date_and_index(conn, request): 2626s # Test case where same column appears in parse_date and index_col 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________________ test_api_timedelta[mysql_pymysql_engine] ___________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_timedelta(conn, request): 2626s # see #6921 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_timedelta", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________________ test_api_timedelta[mysql_pymysql_conn] ____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_timedelta(conn, request): 2626s # see #6921 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________________ test_api_timedelta[postgresql_psycopg2_engine] ________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_timedelta(conn, request): 2626s # see #6921 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_timedelta", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________________ test_api_timedelta[postgresql_psycopg2_conn] _________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_timedelta(conn, request): 2626s # see #6921 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________________ test_api_complex_raises[mysql_pymysql_engine] _________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_complex_raises(conn, request): 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame({"a": [1 + 1j, 2j]}) 2626s 2626s if "adbc" in conn_name: 2626s msg = "datatypes not supported" 2626s else: 2626s msg = "Complex datatypes not supported" 2626s with pytest.raises(ValueError, match=msg): 2626s > assert df.to_sql("test_complex", con=conn) is None 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________________ test_api_complex_raises[mysql_pymysql_conn] __________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_complex_raises(conn, request): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____________ test_api_complex_raises[postgresql_psycopg2_engine] ______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_complex_raises(conn, request): 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame({"a": [1 + 1j, 2j]}) 2626s 2626s if "adbc" in conn_name: 2626s msg = "datatypes not supported" 2626s else: 2626s msg = "Complex datatypes not supported" 2626s with pytest.raises(ValueError, match=msg): 2626s > assert df.to_sql("test_complex", con=conn) is None 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_api_complex_raises[postgresql_psycopg2_conn] _______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_complex_raises(conn, request): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s index_name = None, index_label = None, expected = 'index' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_index_label", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] ________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s index_name = None, index_label = None, expected = 'index' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] ____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s index_name = None, index_label = None, expected = 'index' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_index_label", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s index_name = None, index_label = None, expected = 'index' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s index_name = None, index_label = 'other_label', expected = 'other_label' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_index_label", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s index_name = None, index_label = 'other_label', expected = 'other_label' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s index_name = None, index_label = 'other_label', expected = 'other_label' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_index_label", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s index_name = None, index_label = 'other_label', expected = 'other_label' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s index_name = 'index_name', index_label = None, expected = 'index_name' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_index_label", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] __ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s index_name = 'index_name', index_label = None, expected = 'index_name' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s index_name = 'index_name', index_label = None, expected = 'index_name' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_index_label", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s index_name = 'index_name', index_label = None, expected = 'index_name' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_index_label", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_index_label", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] __________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s index_name = 0, index_label = None, expected = '0' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_index_label", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] ___________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s index_name = 0, index_label = None, expected = '0' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s index_name = 0, index_label = None, expected = '0' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_index_label", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] ________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s index_name = 0, index_label = None, expected = '0' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] __________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s index_name = None, index_label = 0, expected = '0' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_index_label", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] ___________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s index_name = None, index_label = 0, expected = '0' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s index_name = None, index_label = 0, expected = '0' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_index_label", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] ________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s index_name = None, index_label = 0, expected = '0' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "index_name,index_label,expected", 2626s [ 2626s # no index name, defaults to 'index' 2626s (None, None, "index"), 2626s # specifying index_label 2626s (None, "other_label", "other_label"), 2626s # using the index name 2626s ("index_name", None, "index_name"), 2626s # has index name, but specifying index_label 2626s ("index_name", "other_label", "other_label"), 2626s # index name is integer 2626s (0, None, "0"), 2626s # index name is None but index label is integer 2626s (None, 0, "0"), 2626s ], 2626s ) 2626s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] ______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_to_sql_index_label_multiindex(conn, request): 2626s conn_name = conn 2626s if "mysql" in conn_name: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason="MySQL can fail using TEXT without length as key", strict=False 2626s ) 2626s ) 2626s elif "adbc" in conn_name: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_index_label", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2004: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_to_sql_index_label_multiindex(conn, request): 2626s conn_name = conn 2626s if "mysql" in conn_name: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason="MySQL can fail using TEXT without length as key", strict=False 2626s ) 2626s ) 2626s elif "adbc" in conn_name: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2003: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____________ test_api_multiindex_roundtrip[mysql_pymysql_engine] ______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_multiindex_roundtrip(conn, request): 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_multiindex_roundtrip", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______________ test_api_multiindex_roundtrip[mysql_pymysql_conn] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_multiindex_roundtrip(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________ test_api_multiindex_roundtrip[postgresql_psycopg2_engine] ___________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_multiindex_roundtrip(conn, request): 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_multiindex_roundtrip", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________ test_api_multiindex_roundtrip[postgresql_psycopg2_conn] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_multiindex_roundtrip(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_api_dtype_argument[None-mysql_pymysql_engine] ______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s dtype = None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_dtype_argument", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_api_dtype_argument[None-mysql_pymysql_conn] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s dtype = None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_api_dtype_argument[None-postgresql_psycopg2_engine] ___________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s dtype = None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_dtype_argument", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_api_dtype_argument[None-postgresql_psycopg2_conn] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s dtype = None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_api_dtype_argument[int-mysql_pymysql_engine] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s dtype = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_dtype_argument", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_api_dtype_argument[int-mysql_pymysql_conn] ________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s dtype = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_api_dtype_argument[int-postgresql_psycopg2_engine] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s dtype = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_dtype_argument", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_api_dtype_argument[int-postgresql_psycopg2_conn] _____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s dtype = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____________ test_api_dtype_argument[float-mysql_pymysql_engine] ______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s dtype = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_dtype_argument", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______________ test_api_dtype_argument[float-mysql_pymysql_conn] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s dtype = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________ test_api_dtype_argument[float-postgresql_psycopg2_engine] ___________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s dtype = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_dtype_argument", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________ test_api_dtype_argument[float-postgresql_psycopg2_conn] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s dtype = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____________ test_api_dtype_argument[dtype3-mysql_pymysql_engine] _____________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s dtype = {'A': , 'B': } 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_dtype_argument", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______________ test_api_dtype_argument[dtype3-mysql_pymysql_conn] ______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s dtype = {'A': , 'B': } 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________ test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] __________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s dtype = {'A': , 'B': } 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_dtype_argument", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________ test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] ___________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s dtype = {'A': , 'B': } 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize( 2626s "dtype", 2626s [ 2626s None, 2626s int, 2626s float, 2626s {"A": int, "B": float}, 2626s ], 2626s ) 2626s def test_api_dtype_argument(conn, request, dtype): 2626s # GH10285 Add dtype argument to read_sql_query 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______________ test_api_integer_col_names[mysql_pymysql_engine] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_integer_col_names(conn, request): 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 2626s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________________ test_api_integer_col_names[mysql_pymysql_conn] ________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_integer_col_names(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________ test_api_integer_col_names[postgresql_psycopg2_engine] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_integer_col_names(conn, request): 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 2626s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____________ test_api_integer_col_names[postgresql_psycopg2_conn] _____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_integer_col_names(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________________ test_api_get_schema[mysql_pymysql_engine] ___________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema(conn, request, test_frame1): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2626s with pandasSQL_builder(con=con) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________________ test_api_get_schema[mysql_pymysql_conn] ____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema(conn, request, test_frame1): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_api_get_schema[postgresql_psycopg2_engine] ________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema(conn, request, test_frame1): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2626s with pandasSQL_builder(con=con) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________________ test_api_get_schema[postgresql_psycopg2_conn] _________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema(conn, request, test_frame1): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_api_get_schema_with_schema[mysql_pymysql_engine] _____________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema_with_schema(conn, request, test_frame1): 2626s # GH28486 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2626s with pandasSQL_builder(con=con) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____________ test_api_get_schema_with_schema[mysql_pymysql_conn] ______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema_with_schema(conn, request, test_frame1): 2626s # GH28486 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________ test_api_get_schema_with_schema[postgresql_psycopg2_engine] __________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema_with_schema(conn, request, test_frame1): 2626s # GH28486 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2626s with pandasSQL_builder(con=con) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________ test_api_get_schema_with_schema[postgresql_psycopg2_conn] ___________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema_with_schema(conn, request, test_frame1): 2626s # GH28486 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______________ test_api_get_schema_dtypes[mysql_pymysql_engine] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema_dtypes(conn, request): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 2626s 2626s if conn_name == "sqlite_buildin": 2626s dtype = "INTEGER" 2626s else: 2626s from sqlalchemy import Integer 2626s 2626s dtype = Integer 2626s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2626s with pandasSQL_builder(con=con) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________________ test_api_get_schema_dtypes[mysql_pymysql_conn] ________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema_dtypes(conn, request): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________ test_api_get_schema_dtypes[postgresql_psycopg2_engine] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema_dtypes(conn, request): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 2626s 2626s if conn_name == "sqlite_buildin": 2626s dtype = "INTEGER" 2626s else: 2626s from sqlalchemy import Integer 2626s 2626s dtype = Integer 2626s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2626s with pandasSQL_builder(con=con) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____________ test_api_get_schema_dtypes[postgresql_psycopg2_conn] _____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema_dtypes(conn, request): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________________ test_api_get_schema_keys[mysql_pymysql_engine] ________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema_keys(conn, request, test_frame1): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 2626s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2626s with pandasSQL_builder(con=con) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________________ test_api_get_schema_keys[mysql_pymysql_conn] _________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema_keys(conn, request, test_frame1): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____________ test_api_get_schema_keys[postgresql_psycopg2_engine] _____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema_keys(conn, request, test_frame1): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 2626s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2626s with pandasSQL_builder(con=con) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_api_get_schema_keys[postgresql_psycopg2_conn] ______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_get_schema_keys(conn, request, test_frame1): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="'get_schema' not implemented for ADBC drivers", 2626s strict=True, 2626s ) 2626s ) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________________ test_api_chunksize_read[mysql_pymysql_engine] _________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_chunksize_read(conn, request): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2626s ) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_chunksize", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________________ test_api_chunksize_read[mysql_pymysql_conn] __________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_chunksize_read(conn, request): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2626s ) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____________ test_api_chunksize_read[postgresql_psycopg2_engine] ______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_chunksize_read(conn, request): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2626s ) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_chunksize", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_api_chunksize_read[postgresql_psycopg2_conn] _______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_chunksize_read(conn, request): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2626s ) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________________ test_api_categorical[mysql_pymysql_engine] __________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_categorical(conn, request): 2626s if conn == "postgresql_adbc_conn": 2626s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2626s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="categorical dtype not implemented for ADBC postgres driver", 2626s strict=True, 2626s ) 2626s ) 2626s # GH8624 2626s # test that categorical gets written correctly as dense column 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_categorical", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________________ test_api_categorical[mysql_pymysql_conn] ___________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_categorical(conn, request): 2626s if conn == "postgresql_adbc_conn": 2626s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2626s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="categorical dtype not implemented for ADBC postgres driver", 2626s strict=True, 2626s ) 2626s ) 2626s # GH8624 2626s # test that categorical gets written correctly as dense column 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_api_categorical[postgresql_psycopg2_engine] _______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_categorical(conn, request): 2626s if conn == "postgresql_adbc_conn": 2626s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2626s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="categorical dtype not implemented for ADBC postgres driver", 2626s strict=True, 2626s ) 2626s ) 2626s # GH8624 2626s # test that categorical gets written correctly as dense column 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_categorical", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________________ test_api_categorical[postgresql_psycopg2_conn] ________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_categorical(conn, request): 2626s if conn == "postgresql_adbc_conn": 2626s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2626s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="categorical dtype not implemented for ADBC postgres driver", 2626s strict=True, 2626s ) 2626s ) 2626s # GH8624 2626s # test that categorical gets written correctly as dense column 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_api_unicode_column_name[mysql_pymysql_engine] ______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_unicode_column_name(conn, request): 2626s # GH 11431 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_unicode", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_api_unicode_column_name[mysql_pymysql_conn] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_unicode_column_name(conn, request): 2626s # GH 11431 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_api_unicode_column_name[postgresql_psycopg2_engine] ___________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_unicode_column_name(conn, request): 2626s # GH 11431 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_unicode", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_api_unicode_column_name[postgresql_psycopg2_conn] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_unicode_column_name(conn, request): 2626s # GH 11431 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_api_escaped_table_name[mysql_pymysql_engine] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_escaped_table_name(conn, request): 2626s # GH 13206 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_api_escaped_table_name[mysql_pymysql_conn] ________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_escaped_table_name(conn, request): 2626s # GH 13206 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_api_escaped_table_name[postgresql_psycopg2_engine] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_escaped_table_name(conn, request): 2626s # GH 13206 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_api_escaped_table_name[postgresql_psycopg2_conn] _____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_escaped_table_name(conn, request): 2626s # GH 13206 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________ test_api_read_sql_duplicate_columns[mysql_pymysql_engine] ___________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_read_sql_duplicate_columns(conn, request): 2626s # GH#53117 2626s if "adbc" in conn: 2626s pa = pytest.importorskip("pyarrow") 2626s if not ( 2626s Version(pa.__version__) >= Version("16.0") 2626s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2626s ): 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="pyarrow->pandas throws ValueError", strict=True 2626s ) 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_table", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_api_read_sql_duplicate_columns[mysql_pymysql_conn] ____________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_read_sql_duplicate_columns(conn, request): 2626s # GH#53117 2626s if "adbc" in conn: 2626s pa = pytest.importorskip("pyarrow") 2626s if not ( 2626s Version(pa.__version__) >= Version("16.0") 2626s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2626s ): 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="pyarrow->pandas throws ValueError", strict=True 2626s ) 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______ test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] ________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_read_sql_duplicate_columns(conn, request): 2626s # GH#53117 2626s if "adbc" in conn: 2626s pa = pytest.importorskip("pyarrow") 2626s if not ( 2626s Version(pa.__version__) >= Version("16.0") 2626s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2626s ): 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="pyarrow->pandas throws ValueError", strict=True 2626s ) 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s > if sql.has_table("test_table", conn): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2626s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________ test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_api_read_sql_duplicate_columns(conn, request): 2626s # GH#53117 2626s if "adbc" in conn: 2626s pa = pytest.importorskip("pyarrow") 2626s if not ( 2626s Version(pa.__version__) >= Version("16.0") 2626s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2626s ): 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="pyarrow->pandas throws ValueError", strict=True 2626s ) 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________________ test_read_table_columns[mysql_pymysql_engine] _________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_read_table_columns(conn, request, test_frame1): 2626s # test columns argument in read_table 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin": 2626s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2626s 2626s conn = request.getfixturevalue(conn) 2626s > sql.to_sql(test_frame1, "test_frame", conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________________ test_read_table_columns[mysql_pymysql_conn] __________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_read_table_columns(conn, request, test_frame1): 2626s # test columns argument in read_table 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin": 2626s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____________ test_read_table_columns[postgresql_psycopg2_engine] ______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_read_table_columns(conn, request, test_frame1): 2626s # test columns argument in read_table 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin": 2626s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2626s 2626s conn = request.getfixturevalue(conn) 2626s > sql.to_sql(test_frame1, "test_frame", conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_read_table_columns[postgresql_psycopg2_conn] _______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_read_table_columns(conn, request, test_frame1): 2626s # test columns argument in read_table 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin": 2626s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______________ test_read_table_index_col[mysql_pymysql_engine] ________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_read_table_index_col(conn, request, test_frame1): 2626s # test columns argument in read_table 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin": 2626s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2626s 2626s conn = request.getfixturevalue(conn) 2626s > sql.to_sql(test_frame1, "test_frame", conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________________ test_read_table_index_col[mysql_pymysql_conn] _________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_read_table_index_col(conn, request, test_frame1): 2626s # test columns argument in read_table 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin": 2626s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________ test_read_table_index_col[postgresql_psycopg2_engine] _____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_read_table_index_col(conn, request, test_frame1): 2626s # test columns argument in read_table 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin": 2626s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2626s 2626s conn = request.getfixturevalue(conn) 2626s > sql.to_sql(test_frame1, "test_frame", conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____________ test_read_table_index_col[postgresql_psycopg2_conn] ______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_read_table_index_col(conn, request, test_frame1): 2626s # test columns argument in read_table 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin": 2626s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_read_sql_delegate[mysql_pymysql_engine_iris] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_iris) 2626s def test_read_sql_delegate(conn, request): 2626s if conn == "sqlite_buildin_iris": 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason="sqlite_buildin connection does not implement read_sql_table" 2626s ) 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_read_sql_delegate[mysql_pymysql_conn_iris] ________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_iris) 2626s def test_read_sql_delegate(conn, request): 2626s if conn == "sqlite_buildin_iris": 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason="sqlite_buildin connection does not implement read_sql_table" 2626s ) 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_read_sql_delegate[postgresql_psycopg2_engine_iris] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_iris) 2626s def test_read_sql_delegate(conn, request): 2626s if conn == "sqlite_buildin_iris": 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason="sqlite_buildin connection does not implement read_sql_table" 2626s ) 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_read_sql_delegate[postgresql_psycopg2_conn_iris] _____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_iris) 2626s def test_read_sql_delegate(conn, request): 2626s if conn == "sqlite_buildin_iris": 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason="sqlite_buildin connection does not implement read_sql_table" 2626s ) 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________ test_warning_case_insensitive_table_name[mysql_pymysql_engine] ________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2626s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2626s 2626s conn = request.getfixturevalue(conn) 2626s # see gh-7815 2626s with tm.assert_produces_warning( 2626s UserWarning, 2626s match=( 2626s r"The provided table name 'TABLE1' is not found exactly as such in " 2626s r"the database after writing the table, possibly due to case " 2626s r"sensitivity issues. Consider using lower case table names." 2626s ), 2626s ): 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2626s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2626s 2626s conn = request.getfixturevalue(conn) 2626s # see gh-7815 2626s > with tm.assert_produces_warning( 2626s UserWarning, 2626s match=( 2626s r"The provided table name 'TABLE1' is not found exactly as such in " 2626s r"the database after writing the table, possibly due to case " 2626s r"sensitivity issues. Consider using lower case table names." 2626s ), 2626s ): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/contextlib.py:162: in __exit__ 2626s self.gen.throw(value) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s def _assert_caught_expected_warning( 2626s *, 2626s caught_warnings: Sequence[warnings.WarningMessage], 2626s expected_warning: type[Warning], 2626s match: str | None, 2626s check_stacklevel: bool, 2626s ) -> None: 2626s """Assert that there was the expected warning among the caught warnings.""" 2626s saw_warning = False 2626s matched_message = False 2626s unmatched_messages = [] 2626s 2626s for actual_warning in caught_warnings: 2626s if issubclass(actual_warning.category, expected_warning): 2626s saw_warning = True 2626s 2626s if check_stacklevel: 2626s _assert_raised_with_correct_stacklevel(actual_warning) 2626s 2626s if match is not None: 2626s if re.search(match, str(actual_warning.message)): 2626s matched_message = True 2626s else: 2626s unmatched_messages.append(actual_warning.message) 2626s 2626s if not saw_warning: 2626s > raise AssertionError( 2626s f"Did not see expected warning of class " 2626s f"{repr(expected_warning.__name__)}" 2626s ) 2626s E AssertionError: Did not see expected warning of class 'UserWarning' 2626s 2626s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 2626s _________ test_warning_case_insensitive_table_name[mysql_pymysql_conn] _________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2626s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____ test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2626s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2626s 2626s conn = request.getfixturevalue(conn) 2626s # see gh-7815 2626s with tm.assert_produces_warning( 2626s UserWarning, 2626s match=( 2626s r"The provided table name 'TABLE1' is not found exactly as such in " 2626s r"the database after writing the table, possibly due to case " 2626s r"sensitivity issues. Consider using lower case table names." 2626s ), 2626s ): 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2626s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2626s 2626s conn = request.getfixturevalue(conn) 2626s # see gh-7815 2626s > with tm.assert_produces_warning( 2626s UserWarning, 2626s match=( 2626s r"The provided table name 'TABLE1' is not found exactly as such in " 2626s r"the database after writing the table, possibly due to case " 2626s r"sensitivity issues. Consider using lower case table names." 2626s ), 2626s ): 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/contextlib.py:162: in __exit__ 2626s self.gen.throw(value) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s def _assert_caught_expected_warning( 2626s *, 2626s caught_warnings: Sequence[warnings.WarningMessage], 2626s expected_warning: type[Warning], 2626s match: str | None, 2626s check_stacklevel: bool, 2626s ) -> None: 2626s """Assert that there was the expected warning among the caught warnings.""" 2626s saw_warning = False 2626s matched_message = False 2626s unmatched_messages = [] 2626s 2626s for actual_warning in caught_warnings: 2626s if issubclass(actual_warning.category, expected_warning): 2626s saw_warning = True 2626s 2626s if check_stacklevel: 2626s _assert_raised_with_correct_stacklevel(actual_warning) 2626s 2626s if match is not None: 2626s if re.search(match, str(actual_warning.message)): 2626s matched_message = True 2626s else: 2626s unmatched_messages.append(actual_warning.message) 2626s 2626s if not saw_warning: 2626s > raise AssertionError( 2626s f"Did not see expected warning of class " 2626s f"{repr(expected_warning.__name__)}" 2626s ) 2626s E AssertionError: Did not see expected warning of class 'UserWarning' 2626s 2626s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 2626s ______ test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] ______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2626s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_sqlalchemy_type_mapping[mysql_pymysql_engine] ______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_sqlalchemy_type_mapping(conn, request): 2626s conn = request.getfixturevalue(conn) 2626s from sqlalchemy import TIMESTAMP 2626s 2626s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 2626s df = DataFrame( 2626s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 2626s ) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_sqlalchemy_type_mapping[mysql_pymysql_conn] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_sqlalchemy_type_mapping(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] ___________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_sqlalchemy_type_mapping(conn, request): 2626s conn = request.getfixturevalue(conn) 2626s from sqlalchemy import TIMESTAMP 2626s 2626s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 2626s df = DataFrame( 2626s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 2626s ) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_sqlalchemy_type_mapping(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'int8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'int8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'int8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] ____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'int8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'Int8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'Int8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'Int8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] ____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'Int8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _____ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'uint8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'uint8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] __ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'uint8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'uint8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _____ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'UInt8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'UInt8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] __ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'UInt8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'UInt8', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _____ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'int16', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'int16', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] __ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'int16', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'int16', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _____ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'Int16', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'Int16', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] __ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'Int16', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'Int16', expected = 'SMALLINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _____ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'uint16', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'uint16', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] __ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'uint16', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'uint16', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _____ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'UInt16', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'UInt16', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] __ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'UInt16', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'UInt16', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'int32', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'int32', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'int32', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] ____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'int32', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'Int32', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'Int32', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'Int32', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] ____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'Int32', expected = 'INTEGER' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'uint32', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'uint32', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'uint32', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] ____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'uint32', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'UInt32', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'UInt32', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'UInt32', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] ____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'UInt32', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'int64', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'int64', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'int64', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] ____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'int64', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'Int64', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'Int64', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'Int64', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] ____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'Int64', expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______ test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] _______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = , expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________ test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] ________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = , expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____ test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] ____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = , expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____ test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] _____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = , expected = 'BIGINT' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "integer, expected", 2626s [ 2626s ("int8", "SMALLINT"), 2626s ("Int8", "SMALLINT"), 2626s ("uint8", "SMALLINT"), 2626s ("UInt8", "SMALLINT"), 2626s ("int16", "SMALLINT"), 2626s ("Int16", "SMALLINT"), 2626s ("uint16", "INTEGER"), 2626s ("UInt16", "INTEGER"), 2626s ("int32", "INTEGER"), 2626s ("Int32", "INTEGER"), 2626s ("uint32", "BIGINT"), 2626s ("UInt32", "BIGINT"), 2626s ("int64", "BIGINT"), 2626s ("Int64", "BIGINT"), 2626s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2626s ], 2626s ) 2626s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _____ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'uint64' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2626s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2626s conn = request.getfixturevalue(conn) 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'uint64' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2626s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] __ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'uint64' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2626s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2626s conn = request.getfixturevalue(conn) 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'uint64' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2626s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _____ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s integer = 'UInt64' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2626s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2626s conn = request.getfixturevalue(conn) 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] ______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s integer = 'UInt64' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2626s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] __ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s integer = 'UInt64' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2626s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2626s conn = request.getfixturevalue(conn) 2626s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2626s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2626s > with sql.SQLDatabase(conn) as db: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s integer = 'UInt64' 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2626s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________________ test_database_uri_string[mysql_pymysql_conn] _________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_database_uri_string(conn, request, test_frame1): 2626s td.versioned_importorskip("sqlalchemy") 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______________ test_database_uri_string[postgresql_psycopg2_conn] ______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_database_uri_string(conn, request, test_frame1): 2626s td.versioned_importorskip("sqlalchemy") 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________ test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @td.skip_if_installed("pg8000") 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 2626s td.versioned_importorskip("sqlalchemy") 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] ______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @td.skip_if_installed("pg8000") 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 2626s td.versioned_importorskip("sqlalchemy") 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_query_by_text_obj[mysql_pymysql_engine_iris] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_query_by_text_obj(conn, request): 2626s # WIP : GH10846 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_query_by_text_obj[mysql_pymysql_conn_iris] ________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_query_by_text_obj(conn, request): 2626s # WIP : GH10846 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_query_by_text_obj[postgresql_psycopg2_engine_iris] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_query_by_text_obj(conn, request): 2626s # WIP : GH10846 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_query_by_text_obj[postgresql_psycopg2_conn_iris] _____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_query_by_text_obj(conn, request): 2626s # WIP : GH10846 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____________ test_query_by_select_obj[mysql_pymysql_engine_iris] ______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_query_by_select_obj(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______________ test_query_by_select_obj[mysql_pymysql_conn_iris] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_query_by_select_obj(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________ test_query_by_select_obj[postgresql_psycopg2_engine_iris] ___________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_query_by_select_obj(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________ test_query_by_select_obj[postgresql_psycopg2_conn_iris] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_query_by_select_obj(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_column_with_percentage[mysql_pymysql_engine] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_column_with_percentage(conn, request): 2626s # GH 37157 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin": 2626s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2626s 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 2626s > df.to_sql(name="test_column_percentage", con=conn, index=False) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_column_with_percentage[mysql_pymysql_conn] ________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_column_with_percentage(conn, request): 2626s # GH 37157 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin": 2626s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_column_with_percentage[postgresql_psycopg2_engine] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_column_with_percentage(conn, request): 2626s # GH 37157 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin": 2626s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2626s 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 2626s > df.to_sql(name="test_column_percentage", con=conn, index=False) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_column_with_percentage[postgresql_psycopg2_conn] _____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_column_with_percentage(conn, request): 2626s # GH 37157 2626s conn_name = conn 2626s if conn_name == "sqlite_buildin": 2626s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________________ test_create_table[mysql_pymysql_engine] ____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_create_table(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import inspect 2626s 2626s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2626s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________________ test_create_table[mysql_pymysql_conn] _____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_create_table(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________________ test_create_table[postgresql_psycopg2_engine] _________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_create_table(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import inspect 2626s 2626s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2626s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________________ test_create_table[postgresql_psycopg2_conn] __________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_create_table(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________________ test_drop_table[mysql_pymysql_engine] _____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_drop_table(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import inspect 2626s 2626s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2626s > with sql.SQLDatabase(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____________________ test_drop_table[mysql_pymysql_conn] ______________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_drop_table(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________________ test_drop_table[postgresql_psycopg2_engine] __________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_drop_table(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import inspect 2626s 2626s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2626s > with sql.SQLDatabase(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________________ test_drop_table[postgresql_psycopg2_conn] ___________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_drop_table(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____________________ test_roundtrip[mysql_pymysql_engine] _____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_roundtrip(conn, request, test_frame1): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > pandasSQL = pandasSQL_builder(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______________________ test_roundtrip[mysql_pymysql_conn] ______________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_roundtrip(conn, request, test_frame1): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________________ test_roundtrip[postgresql_psycopg2_engine] __________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_roundtrip(conn, request, test_frame1): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > pandasSQL = pandasSQL_builder(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________________ test_roundtrip[postgresql_psycopg2_conn] ___________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_roundtrip(conn, request, test_frame1): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________________ test_execute_sql[mysql_pymysql_engine_iris] __________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_iris) 2626s def test_execute_sql(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________________ test_execute_sql[mysql_pymysql_conn_iris] ___________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_iris) 2626s def test_execute_sql(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______________ test_execute_sql[postgresql_psycopg2_engine_iris] _______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_iris) 2626s def test_execute_sql(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______________ test_execute_sql[postgresql_psycopg2_conn_iris] ________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable_iris) 2626s def test_execute_sql(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_sqlalchemy_read_table[mysql_pymysql_engine_iris] _____________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_sqlalchemy_read_table(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____________ test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_sqlalchemy_read_table(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________ test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] __________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_sqlalchemy_read_table(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________ test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] ___________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_sqlalchemy_read_table(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________ test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_sqlalchemy_read_table_columns(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________ test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] __________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_sqlalchemy_read_table_columns(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____ test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] ______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_sqlalchemy_read_table_columns(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______ test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_sqlalchemy_read_table_columns(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________ test_read_table_absent_raises[mysql_pymysql_engine_iris] ___________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_read_table_absent_raises(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________ test_read_table_absent_raises[mysql_pymysql_conn_iris] ____________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_read_table_absent_raises(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2626s create_and_load_iris(mysql_pymysql_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________ test_read_table_absent_raises[postgresql_psycopg2_engine_iris] ________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_read_table_absent_raises(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________ test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_iris' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2626s def test_read_table_absent_raises(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2626s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2626s with conn.begin() as con: 2626s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2626s return next(self.gen) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2626s with self.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2626s def test_sqlalchemy_default_type_conversion(conn, request): 2626s conn_name = conn 2626s if conn_name == "sqlite_str": 2626s pytest.skip("types tables not created in sqlite_str fixture") 2626s elif "mysql" in conn_name or "sqlite" in conn_name: 2626s request.applymarker( 2626s pytest.mark.xfail(reason="boolean dtype not inferred properly") 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] ____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2626s def test_sqlalchemy_default_type_conversion(conn, request): 2626s conn_name = conn 2626s if conn_name == "sqlite_str": 2626s pytest.skip("types tables not created in sqlite_str fixture") 2626s elif "mysql" in conn_name or "sqlite" in conn_name: 2626s request.applymarker( 2626s pytest.mark.xfail(reason="boolean dtype not inferred properly") 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________________ test_bigint[mysql_pymysql_engine] _______________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_bigint(conn, request): 2626s # int64 should be converted to BigInteger, GH7433 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame(data={"i64": [2**62]}) 2626s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________________ test_bigint[mysql_pymysql_conn] ________________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_bigint(conn, request): 2626s # int64 should be converted to BigInteger, GH7433 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________________ test_bigint[postgresql_psycopg2_engine] ____________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_bigint(conn, request): 2626s # int64 should be converted to BigInteger, GH7433 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame(data={"i64": [2**62]}) 2626s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________________ test_bigint[postgresql_psycopg2_conn] _____________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_bigint(conn, request): 2626s # int64 should be converted to BigInteger, GH7433 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_default_date_load[mysql_pymysql_engine_types] ______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2626s def test_default_date_load(conn, request): 2626s conn_name = conn 2626s if conn_name == "sqlite_str": 2626s pytest.skip("types tables not created in sqlite_str fixture") 2626s elif "sqlite" in conn_name: 2626s request.applymarker( 2626s pytest.mark.xfail(reason="sqlite does not read date properly") 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_default_date_load[mysql_pymysql_conn_types] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2626s def test_default_date_load(conn, request): 2626s conn_name = conn 2626s if conn_name == "sqlite_str": 2626s pytest.skip("types tables not created in sqlite_str fixture") 2626s elif "sqlite" in conn_name: 2626s request.applymarker( 2626s pytest.mark.xfail(reason="sqlite does not read date properly") 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_default_date_load[postgresql_psycopg2_engine_types] ___________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2626s def test_default_date_load(conn, request): 2626s conn_name = conn 2626s if conn_name == "sqlite_str": 2626s pytest.skip("types tables not created in sqlite_str fixture") 2626s elif "sqlite" in conn_name: 2626s request.applymarker( 2626s pytest.mark.xfail(reason="sqlite does not read date properly") 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_default_date_load[postgresql_psycopg2_conn_types] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2626s def test_default_date_load(conn, request): 2626s conn_name = conn 2626s if conn_name == "sqlite_str": 2626s pytest.skip("types tables not created in sqlite_str fixture") 2626s elif "sqlite" in conn_name: 2626s request.applymarker( 2626s pytest.mark.xfail(reason="sqlite does not read date properly") 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______ test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] ______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s parse_dates = None 2626s 2626s @pytest.mark.parametrize("conn", postgresql_connectable) 2626s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2626s def test_datetime_with_timezone_query(conn, request, parse_dates): 2626s # edge case that converts postgresql datetime with time zone types 2626s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2626s # but should be more natural, so coerce to datetime64[ns] for now 2626s conn = request.getfixturevalue(conn) 2626s > expected = create_and_load_postgres_datetz(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______ test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s parse_dates = None 2626s 2626s @pytest.mark.parametrize("conn", postgresql_connectable) 2626s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2626s def test_datetime_with_timezone_query(conn, request, parse_dates): 2626s # edge case that converts postgresql datetime with time zone types 2626s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2626s # but should be more natural, so coerce to datetime64[ns] for now 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] __ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s parse_dates = ['DateColWithTz'] 2626s 2626s @pytest.mark.parametrize("conn", postgresql_connectable) 2626s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2626s def test_datetime_with_timezone_query(conn, request, parse_dates): 2626s # edge case that converts postgresql datetime with time zone types 2626s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2626s # but should be more natural, so coerce to datetime64[ns] for now 2626s conn = request.getfixturevalue(conn) 2626s > expected = create_and_load_postgres_datetz(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] ___ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s parse_dates = ['DateColWithTz'] 2626s 2626s @pytest.mark.parametrize("conn", postgresql_connectable) 2626s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2626s def test_datetime_with_timezone_query(conn, request, parse_dates): 2626s # edge case that converts postgresql datetime with time zone types 2626s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2626s # but should be more natural, so coerce to datetime64[ns] for now 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] ____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", postgresql_connectable) 2626s def test_datetime_with_timezone_query_chunksize(conn, request): 2626s conn = request.getfixturevalue(conn) 2626s > expected = create_and_load_postgres_datetz(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2843: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", postgresql_connectable) 2626s def test_datetime_with_timezone_query_chunksize(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2842: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________ test_datetime_with_timezone_table[postgresql_psycopg2_engine] _________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", postgresql_connectable) 2626s def test_datetime_with_timezone_table(conn, request): 2626s conn = request.getfixturevalue(conn) 2626s > expected = create_and_load_postgres_datetz(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2856: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________ test_datetime_with_timezone_table[postgresql_psycopg2_conn] __________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", postgresql_connectable) 2626s def test_datetime_with_timezone_table(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2855: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________ test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] __________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_with_timezone_roundtrip(conn, request): 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s # GH 9086 2626s # Write datetimetz data to a db and read it back 2626s # For dbs that support timestamps with timezones, should get back UTC 2626s # otherwise naive data should be returned 2626s expected = DataFrame( 2626s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 2626s ) 2626s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________ test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] ___________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_with_timezone_roundtrip(conn, request): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_with_timezone_roundtrip(conn, request): 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s # GH 9086 2626s # Write datetimetz data to a db and read it back 2626s # For dbs that support timestamps with timezones, should get back UTC 2626s # otherwise naive data should be returned 2626s expected = DataFrame( 2626s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 2626s ) 2626s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] ________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_with_timezone_roundtrip(conn, request): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_out_of_bounds_datetime[mysql_pymysql_engine] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_out_of_bounds_datetime(conn, request): 2626s # GH 26761 2626s conn = request.getfixturevalue(conn) 2626s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 2626s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_out_of_bounds_datetime[mysql_pymysql_conn] ________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_out_of_bounds_datetime(conn, request): 2626s # GH 26761 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_out_of_bounds_datetime[postgresql_psycopg2_engine] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_out_of_bounds_datetime(conn, request): 2626s # GH 26761 2626s conn = request.getfixturevalue(conn) 2626s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 2626s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_out_of_bounds_datetime[postgresql_psycopg2_conn] _____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_out_of_bounds_datetime(conn, request): 2626s # GH 26761 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________ test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] ___________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_naive_datetimeindex_roundtrip(conn, request): 2626s # GH 23510 2626s # Ensure that a naive DatetimeIndex isn't converted to UTC 2626s conn = request.getfixturevalue(conn) 2626s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 2626s expected = DataFrame({"nums": range(5)}, index=dates) 2626s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________ test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] ____________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_naive_datetimeindex_roundtrip(conn, request): 2626s # GH 23510 2626s # Ensure that a naive DatetimeIndex isn't converted to UTC 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] ________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_naive_datetimeindex_roundtrip(conn, request): 2626s # GH 23510 2626s # Ensure that a naive DatetimeIndex isn't converted to UTC 2626s conn = request.getfixturevalue(conn) 2626s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 2626s expected = DataFrame({"nums": range(5)}, index=dates) 2626s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_naive_datetimeindex_roundtrip(conn, request): 2626s # GH 23510 2626s # Ensure that a naive DatetimeIndex isn't converted to UTC 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________________ test_date_parsing[mysql_pymysql_engine_types] _________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_engine_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2626s def test_date_parsing(conn, request): 2626s # No Parsing 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________________ test_date_parsing[mysql_pymysql_conn_types] __________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2626s def test_date_parsing(conn, request): 2626s # No Parsing 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2626s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____________ test_date_parsing[postgresql_psycopg2_engine_types] ______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_engine_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2626s def test_date_parsing(conn, request): 2626s # No Parsing 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_date_parsing[postgresql_psycopg2_conn_types] _______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn_types' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2626s def test_date_parsing(conn, request): 2626s # No Parsing 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2626s fixturedef = request._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2626s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2626s with conn.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____________________ test_datetime[mysql_pymysql_engine] ______________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime(conn, request): 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame( 2626s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2626s ) 2626s > assert df.to_sql(name="test_datetime", con=conn) == 3 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______________________ test_datetime[mysql_pymysql_conn] _______________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime(conn, request): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________________ test_datetime[postgresql_psycopg2_engine] ___________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime(conn, request): 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame( 2626s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2626s ) 2626s > assert df.to_sql(name="test_datetime", con=conn) == 3 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________________ test_datetime[postgresql_psycopg2_conn] ____________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime(conn, request): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________________ test_datetime_NaT[mysql_pymysql_engine] ____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_NaT(conn, request): 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame( 2626s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2626s ) 2626s df.loc[1, "A"] = np.nan 2626s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________________ test_datetime_NaT[mysql_pymysql_conn] _____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_NaT(conn, request): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________________ test_datetime_NaT[postgresql_psycopg2_engine] _________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_NaT(conn, request): 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame( 2626s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2626s ) 2626s df.loc[1, "A"] = np.nan 2626s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________________ test_datetime_NaT[postgresql_psycopg2_conn] __________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_NaT(conn, request): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________________ test_datetime_date[mysql_pymysql_engine] ___________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_date(conn, request): 2626s # test support for datetime.date 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 2626s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________________ test_datetime_date[mysql_pymysql_conn] ____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_date(conn, request): 2626s # test support for datetime.date 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________________ test_datetime_date[postgresql_psycopg2_engine] ________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_date(conn, request): 2626s # test support for datetime.date 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 2626s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________________ test_datetime_date[postgresql_psycopg2_conn] _________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_date(conn, request): 2626s # test support for datetime.date 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________________ test_datetime_time[mysql_pymysql_engine] ___________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s sqlite_buildin = 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_time(conn, request, sqlite_buildin): 2626s # test support for datetime.time 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 2626s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________________ test_datetime_time[mysql_pymysql_conn] ____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s sqlite_buildin = 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_time(conn, request, sqlite_buildin): 2626s # test support for datetime.time 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________________ test_datetime_time[postgresql_psycopg2_engine] ________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s sqlite_buildin = 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_time(conn, request, sqlite_buildin): 2626s # test support for datetime.time 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 2626s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________________ test_datetime_time[postgresql_psycopg2_conn] _________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s sqlite_buildin = 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_datetime_time(conn, request, sqlite_buildin): 2626s # test support for datetime.time 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________________ test_mixed_dtype_insert[mysql_pymysql_engine] _________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_mixed_dtype_insert(conn, request): 2626s # see GH6509 2626s conn = request.getfixturevalue(conn) 2626s s1 = Series(2**25 + 1, dtype=np.int32) 2626s s2 = Series(0.0, dtype=np.float32) 2626s df = DataFrame({"s1": s1, "s2": s2}) 2626s 2626s # write and read again 2626s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________________ test_mixed_dtype_insert[mysql_pymysql_conn] __________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_mixed_dtype_insert(conn, request): 2626s # see GH6509 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____________ test_mixed_dtype_insert[postgresql_psycopg2_engine] ______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_mixed_dtype_insert(conn, request): 2626s # see GH6509 2626s conn = request.getfixturevalue(conn) 2626s s1 = Series(2**25 + 1, dtype=np.int32) 2626s s2 = Series(0.0, dtype=np.float32) 2626s df = DataFrame({"s1": s1, "s2": s2}) 2626s 2626s # write and read again 2626s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_mixed_dtype_insert[postgresql_psycopg2_conn] _______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_mixed_dtype_insert(conn, request): 2626s # see GH6509 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________________ test_nan_numeric[mysql_pymysql_engine] ____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_nan_numeric(conn, request): 2626s # NaNs in numeric float column 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 2626s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____________________ test_nan_numeric[mysql_pymysql_conn] _____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_nan_numeric(conn, request): 2626s # NaNs in numeric float column 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________________ test_nan_numeric[postgresql_psycopg2_engine] _________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_nan_numeric(conn, request): 2626s # NaNs in numeric float column 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 2626s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________________ test_nan_numeric[postgresql_psycopg2_conn] __________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_nan_numeric(conn, request): 2626s # NaNs in numeric float column 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________________ test_nan_fullcolumn[mysql_pymysql_engine] ___________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_nan_fullcolumn(conn, request): 2626s # full NaN column (numeric float column) 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 2626s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________________ test_nan_fullcolumn[mysql_pymysql_conn] ____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_nan_fullcolumn(conn, request): 2626s # full NaN column (numeric float column) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_nan_fullcolumn[postgresql_psycopg2_engine] ________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_nan_fullcolumn(conn, request): 2626s # full NaN column (numeric float column) 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 2626s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________________ test_nan_fullcolumn[postgresql_psycopg2_conn] _________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_nan_fullcolumn(conn, request): 2626s # full NaN column (numeric float column) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________________ test_nan_string[mysql_pymysql_engine] _____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_nan_string(conn, request): 2626s # NaNs in string column 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 2626s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____________________ test_nan_string[mysql_pymysql_conn] ______________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_nan_string(conn, request): 2626s # NaNs in string column 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________________ test_nan_string[postgresql_psycopg2_engine] __________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_nan_string(conn, request): 2626s # NaNs in string column 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 2626s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________________ test_nan_string[postgresql_psycopg2_conn] ___________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_nan_string(conn, request): 2626s # NaNs in string column 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________________ test_to_sql_save_index[mysql_pymysql_engine] _________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_to_sql_save_index(conn, request): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="ADBC implementation does not create index", strict=True 2626s ) 2626s ) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame.from_records( 2626s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 2626s ) 2626s 2626s tbl_name = "test_to_sql_saves_index" 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________________ test_to_sql_save_index[mysql_pymysql_conn] __________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_to_sql_save_index(conn, request): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="ADBC implementation does not create index", strict=True 2626s ) 2626s ) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______________ test_to_sql_save_index[postgresql_psycopg2_engine] ______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_to_sql_save_index(conn, request): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="ADBC implementation does not create index", strict=True 2626s ) 2626s ) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s df = DataFrame.from_records( 2626s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 2626s ) 2626s 2626s tbl_name = "test_to_sql_saves_index" 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______________ test_to_sql_save_index[postgresql_psycopg2_conn] _______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_to_sql_save_index(conn, request): 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail( 2626s reason="ADBC implementation does not create index", strict=True 2626s ) 2626s ) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________________ test_transactions[mysql_pymysql_engine] ____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_transactions(conn, request): 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s 2626s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 2626s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 2626s from sqlalchemy import text 2626s 2626s stmt = text(stmt) 2626s 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________________ test_transactions[mysql_pymysql_conn] _____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_transactions(conn, request): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________________ test_transactions[postgresql_psycopg2_engine] _________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_transactions(conn, request): 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s 2626s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 2626s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 2626s from sqlalchemy import text 2626s 2626s stmt = text(stmt) 2626s 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________________ test_transactions[postgresql_psycopg2_conn] __________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_transactions(conn, request): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______________ test_transaction_rollback[mysql_pymysql_engine] ________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_transaction_rollback(conn, request): 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________________ test_transaction_rollback[mysql_pymysql_conn] _________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_transaction_rollback(conn, request): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________ test_transaction_rollback[postgresql_psycopg2_engine] _____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_transaction_rollback(conn, request): 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____________ test_transaction_rollback[postgresql_psycopg2_conn] ______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_transaction_rollback(conn, request): 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_get_schema_create_table[mysql_pymysql_engine] ______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s test_frame3 = index A B 2626s 0 2000-01-03 00:00:00 2147483647 -1.987670 2626s 1 2000-01-04 00:00:00 -29 -0.041232 2626s 2 2000-01-05 00:00:00 20000 0.731168 2626s 3 2000-01-06 00:00:00 -290867 1.567621 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_get_schema_create_table(conn, request, test_frame3): 2626s # Use a dataframe without a bool column, since MySQL converts bool to 2626s # TINYINT (which read_sql_table returns as an int and causes a dtype 2626s # mismatch) 2626s if conn == "sqlite_str": 2626s request.applymarker( 2626s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2626s ) 2626s 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import text 2626s from sqlalchemy.engine import Engine 2626s 2626s tbl = "test_get_schema_create_table" 2626s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2626s with pandasSQL_builder(con=con) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_get_schema_create_table[mysql_pymysql_conn] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s test_frame3 = index A B 2626s 0 2000-01-03 00:00:00 2147483647 -1.987670 2626s 1 2000-01-04 00:00:00 -29 -0.041232 2626s 2 2000-01-05 00:00:00 20000 0.731168 2626s 3 2000-01-06 00:00:00 -290867 1.567621 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_get_schema_create_table(conn, request, test_frame3): 2626s # Use a dataframe without a bool column, since MySQL converts bool to 2626s # TINYINT (which read_sql_table returns as an int and causes a dtype 2626s # mismatch) 2626s if conn == "sqlite_str": 2626s request.applymarker( 2626s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_get_schema_create_table[postgresql_psycopg2_engine] ___________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s test_frame3 = index A B 2626s 0 2000-01-03 00:00:00 2147483647 -1.987670 2626s 1 2000-01-04 00:00:00 -29 -0.041232 2626s 2 2000-01-05 00:00:00 20000 0.731168 2626s 3 2000-01-06 00:00:00 -290867 1.567621 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_get_schema_create_table(conn, request, test_frame3): 2626s # Use a dataframe without a bool column, since MySQL converts bool to 2626s # TINYINT (which read_sql_table returns as an int and causes a dtype 2626s # mismatch) 2626s if conn == "sqlite_str": 2626s request.applymarker( 2626s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2626s ) 2626s 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import text 2626s from sqlalchemy.engine import Engine 2626s 2626s tbl = "test_get_schema_create_table" 2626s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2626s with pandasSQL_builder(con=con) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_get_schema_create_table[postgresql_psycopg2_conn] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s test_frame3 = index A B 2626s 0 2000-01-03 00:00:00 2147483647 -1.987670 2626s 1 2000-01-04 00:00:00 -29 -0.041232 2626s 2 2000-01-05 00:00:00 20000 0.731168 2626s 3 2000-01-06 00:00:00 -290867 1.567621 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_get_schema_create_table(conn, request, test_frame3): 2626s # Use a dataframe without a bool column, since MySQL converts bool to 2626s # TINYINT (which read_sql_table returns as an int and causes a dtype 2626s # mismatch) 2626s if conn == "sqlite_str": 2626s request.applymarker( 2626s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______________________ test_dtype[mysql_pymysql_engine] _______________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_dtype(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import ( 2626s TEXT, 2626s String, 2626s ) 2626s from sqlalchemy.schema import MetaData 2626s 2626s cols = ["A", "B"] 2626s data = [(0.8, True), (0.9, None)] 2626s df = DataFrame(data, columns=cols) 2626s > assert df.to_sql(name="dtype_test", con=conn) == 2 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________________________ test_dtype[mysql_pymysql_conn] ________________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_dtype(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________________ test_dtype[postgresql_psycopg2_engine] ____________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_dtype(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import ( 2626s TEXT, 2626s String, 2626s ) 2626s from sqlalchemy.schema import MetaData 2626s 2626s cols = ["A", "B"] 2626s data = [(0.8, True), (0.9, None)] 2626s df = DataFrame(data, columns=cols) 2626s > assert df.to_sql(name="dtype_test", con=conn) == 2 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____________________ test_dtype[postgresql_psycopg2_conn] _____________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_dtype(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________________ test_notna_dtype[mysql_pymysql_engine] ____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_notna_dtype(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import ( 2626s Boolean, 2626s DateTime, 2626s Float, 2626s Integer, 2626s ) 2626s from sqlalchemy.schema import MetaData 2626s 2626s cols = { 2626s "Bool": Series([True, None]), 2626s "Date": Series([datetime(2012, 5, 1), None]), 2626s "Int": Series([1, None], dtype="object"), 2626s "Float": Series([1.1, None]), 2626s } 2626s df = DataFrame(cols) 2626s 2626s tbl = "notna_dtype_test" 2626s > assert df.to_sql(name=tbl, con=conn) == 2 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____________________ test_notna_dtype[mysql_pymysql_conn] _____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_notna_dtype(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________________ test_notna_dtype[postgresql_psycopg2_engine] _________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_notna_dtype(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import ( 2626s Boolean, 2626s DateTime, 2626s Float, 2626s Integer, 2626s ) 2626s from sqlalchemy.schema import MetaData 2626s 2626s cols = { 2626s "Bool": Series([True, None]), 2626s "Date": Series([datetime(2012, 5, 1), None]), 2626s "Int": Series([1, None], dtype="object"), 2626s "Float": Series([1.1, None]), 2626s } 2626s df = DataFrame(cols) 2626s 2626s tbl = "notna_dtype_test" 2626s > assert df.to_sql(name=tbl, con=conn) == 2 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________________ test_notna_dtype[postgresql_psycopg2_conn] __________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_notna_dtype(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________________ test_double_precision[mysql_pymysql_engine] __________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_double_precision(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import ( 2626s BigInteger, 2626s Float, 2626s Integer, 2626s ) 2626s from sqlalchemy.schema import MetaData 2626s 2626s V = 1.23456789101112131415 2626s 2626s df = DataFrame( 2626s { 2626s "f32": Series([V], dtype="float32"), 2626s "f64": Series([V], dtype="float64"), 2626s "f64_as_f32": Series([V], dtype="float64"), 2626s "i32": Series([5], dtype="int32"), 2626s "i64": Series([5], dtype="int64"), 2626s } 2626s ) 2626s 2626s assert ( 2626s > df.to_sql( 2626s name="test_dtypes", 2626s con=conn, 2626s index=False, 2626s if_exists="replace", 2626s dtype={"f64_as_f32": Float(precision=23)}, 2626s ) 2626s == 1 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________________ test_double_precision[mysql_pymysql_conn] ___________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_double_precision(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______________ test_double_precision[postgresql_psycopg2_engine] _______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_double_precision(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import ( 2626s BigInteger, 2626s Float, 2626s Integer, 2626s ) 2626s from sqlalchemy.schema import MetaData 2626s 2626s V = 1.23456789101112131415 2626s 2626s df = DataFrame( 2626s { 2626s "f32": Series([V], dtype="float32"), 2626s "f64": Series([V], dtype="float64"), 2626s "f64_as_f32": Series([V], dtype="float64"), 2626s "i32": Series([5], dtype="int32"), 2626s "i64": Series([5], dtype="int64"), 2626s } 2626s ) 2626s 2626s assert ( 2626s > df.to_sql( 2626s name="test_dtypes", 2626s con=conn, 2626s index=False, 2626s if_exists="replace", 2626s dtype={"f64_as_f32": Float(precision=23)}, 2626s ) 2626s == 1 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______________ test_double_precision[postgresql_psycopg2_conn] ________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_double_precision(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("sqlite_str has no inspection system") 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _____________ test_connectable_issue_example[mysql_pymysql_engine] _____________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_connectable_issue_example(conn, request): 2626s conn = request.getfixturevalue(conn) 2626s 2626s # This tests the example raised in issue 2626s # https://github.com/pandas-dev/pandas/issues/10104 2626s from sqlalchemy.engine import Engine 2626s 2626s def test_select(connection): 2626s query = "SELECT test_foo_data FROM test_foo_data" 2626s return sql.read_sql_query(query, con=connection) 2626s 2626s def test_append(connection, data): 2626s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 2626s 2626s def test_connectable(conn): 2626s # https://github.com/sqlalchemy/sqlalchemy/commit/ 2626s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 2626s foo_data = test_select(conn) 2626s test_append(conn, foo_data) 2626s 2626s def main(connectable): 2626s if isinstance(connectable, Engine): 2626s with connectable.connect() as conn: 2626s with conn.begin(): 2626s test_connectable(conn) 2626s else: 2626s test_connectable(connectable) 2626s 2626s assert ( 2626s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 2626s == 3 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______________ test_connectable_issue_example[mysql_pymysql_conn] ______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_connectable_issue_example(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________ test_connectable_issue_example[postgresql_psycopg2_engine] __________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_connectable_issue_example(conn, request): 2626s conn = request.getfixturevalue(conn) 2626s 2626s # This tests the example raised in issue 2626s # https://github.com/pandas-dev/pandas/issues/10104 2626s from sqlalchemy.engine import Engine 2626s 2626s def test_select(connection): 2626s query = "SELECT test_foo_data FROM test_foo_data" 2626s return sql.read_sql_query(query, con=connection) 2626s 2626s def test_append(connection, data): 2626s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 2626s 2626s def test_connectable(conn): 2626s # https://github.com/sqlalchemy/sqlalchemy/commit/ 2626s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 2626s foo_data = test_select(conn) 2626s test_append(conn, foo_data) 2626s 2626s def main(connectable): 2626s if isinstance(connectable, Engine): 2626s with connectable.connect() as conn: 2626s with conn.begin(): 2626s test_connectable(conn) 2626s else: 2626s test_connectable(connectable) 2626s 2626s assert ( 2626s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 2626s == 3 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________ test_connectable_issue_example[postgresql_psycopg2_conn] ___________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_connectable_issue_example(conn, request): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s input = {'foo': [inf]} 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "input", 2626s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2626s ) 2626s def test_to_sql_with_negative_npinf(conn, request, input): 2626s # GH 34431 2626s 2626s df = DataFrame(input) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s 2626s if "mysql" in conn_name: 2626s # GH 36465 2626s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2626s # for pymysql version >= 0.10 2626s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2626s pymysql = td.versioned_importorskip("pymysql") 2626s 2626s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2626s mark = pytest.mark.xfail(reason="GH 36465") 2626s request.applymarker(mark) 2626s 2626s msg = "inf cannot be used with MySQL" 2626s with pytest.raises(ValueError, match=msg): 2626s > df.to_sql(name="foobar", con=conn, index=False) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] __________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s input = {'foo': [inf]} 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "input", 2626s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2626s ) 2626s def test_to_sql_with_negative_npinf(conn, request, input): 2626s # GH 34431 2626s 2626s df = DataFrame(input) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] ______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s input = {'foo': [inf]} 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "input", 2626s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2626s ) 2626s def test_to_sql_with_negative_npinf(conn, request, input): 2626s # GH 34431 2626s 2626s df = DataFrame(input) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s 2626s if "mysql" in conn_name: 2626s # GH 36465 2626s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2626s # for pymysql version >= 0.10 2626s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2626s pymysql = td.versioned_importorskip("pymysql") 2626s 2626s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2626s mark = pytest.mark.xfail(reason="GH 36465") 2626s request.applymarker(mark) 2626s 2626s msg = "inf cannot be used with MySQL" 2626s with pytest.raises(ValueError, match=msg): 2626s df.to_sql(name="foobar", con=conn, index=False) 2626s else: 2626s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s input = {'foo': [inf]} 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "input", 2626s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2626s ) 2626s def test_to_sql_with_negative_npinf(conn, request, input): 2626s # GH 34431 2626s 2626s df = DataFrame(input) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s input = {'foo': [-inf]} 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "input", 2626s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2626s ) 2626s def test_to_sql_with_negative_npinf(conn, request, input): 2626s # GH 34431 2626s 2626s df = DataFrame(input) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s 2626s if "mysql" in conn_name: 2626s # GH 36465 2626s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2626s # for pymysql version >= 0.10 2626s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2626s pymysql = td.versioned_importorskip("pymysql") 2626s 2626s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2626s mark = pytest.mark.xfail(reason="GH 36465") 2626s request.applymarker(mark) 2626s 2626s msg = "inf cannot be used with MySQL" 2626s with pytest.raises(ValueError, match=msg): 2626s > df.to_sql(name="foobar", con=conn, index=False) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] __________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s input = {'foo': [-inf]} 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "input", 2626s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2626s ) 2626s def test_to_sql_with_negative_npinf(conn, request, input): 2626s # GH 34431 2626s 2626s df = DataFrame(input) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] ______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s input = {'foo': [-inf]} 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "input", 2626s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2626s ) 2626s def test_to_sql_with_negative_npinf(conn, request, input): 2626s # GH 34431 2626s 2626s df = DataFrame(input) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s 2626s if "mysql" in conn_name: 2626s # GH 36465 2626s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2626s # for pymysql version >= 0.10 2626s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2626s pymysql = td.versioned_importorskip("pymysql") 2626s 2626s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2626s mark = pytest.mark.xfail(reason="GH 36465") 2626s request.applymarker(mark) 2626s 2626s msg = "inf cannot be used with MySQL" 2626s with pytest.raises(ValueError, match=msg): 2626s df.to_sql(name="foobar", con=conn, index=False) 2626s else: 2626s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s input = {'foo': [-inf]} 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "input", 2626s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2626s ) 2626s def test_to_sql_with_negative_npinf(conn, request, input): 2626s # GH 34431 2626s 2626s df = DataFrame(input) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s input = {'foo': [-inf], 'infe0': ['bar']} 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "input", 2626s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2626s ) 2626s def test_to_sql_with_negative_npinf(conn, request, input): 2626s # GH 34431 2626s 2626s df = DataFrame(input) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s 2626s if "mysql" in conn_name: 2626s # GH 36465 2626s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2626s # for pymysql version >= 0.10 2626s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2626s pymysql = td.versioned_importorskip("pymysql") 2626s 2626s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2626s mark = pytest.mark.xfail(reason="GH 36465") 2626s request.applymarker(mark) 2626s 2626s msg = "inf cannot be used with MySQL" 2626s with pytest.raises(ValueError, match=msg): 2626s > df.to_sql(name="foobar", con=conn, index=False) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s __________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] __________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s input = {'foo': [-inf], 'infe0': ['bar']} 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "input", 2626s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2626s ) 2626s def test_to_sql_with_negative_npinf(conn, request, input): 2626s # GH 34431 2626s 2626s df = DataFrame(input) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] ______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s input = {'foo': [-inf], 'infe0': ['bar']} 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "input", 2626s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2626s ) 2626s def test_to_sql_with_negative_npinf(conn, request, input): 2626s # GH 34431 2626s 2626s df = DataFrame(input) 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s 2626s if "mysql" in conn_name: 2626s # GH 36465 2626s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2626s # for pymysql version >= 0.10 2626s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2626s pymysql = td.versioned_importorskip("pymysql") 2626s 2626s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2626s mark = pytest.mark.xfail(reason="GH 36465") 2626s request.applymarker(mark) 2626s 2626s msg = "inf cannot be used with MySQL" 2626s with pytest.raises(ValueError, match=msg): 2626s df.to_sql(name="foobar", con=conn, index=False) 2626s else: 2626s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _______ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s input = {'foo': [-inf], 'infe0': ['bar']} 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s @pytest.mark.parametrize( 2626s "input", 2626s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2626s ) 2626s def test_to_sql_with_negative_npinf(conn, request, input): 2626s # GH 34431 2626s 2626s df = DataFrame(input) 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________________ test_temporary_table[mysql_pymysql_engine] __________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_temporary_table(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("test does not work with str connection") 2626s 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import ( 2626s Column, 2626s Integer, 2626s Unicode, 2626s select, 2626s ) 2626s from sqlalchemy.orm import ( 2626s Session, 2626s declarative_base, 2626s ) 2626s 2626s test_data = "Hello, World!" 2626s expected = DataFrame({"spam": [test_data]}) 2626s Base = declarative_base() 2626s 2626s class Temporary(Base): 2626s __tablename__ = "temp_test" 2626s __table_args__ = {"prefixes": ["TEMPORARY"]} 2626s id = Column(Integer, primary_key=True) 2626s spam = Column(Unicode(30), nullable=False) 2626s 2626s with Session(conn) as session: 2626s with session.begin(): 2626s > conn = session.connection() 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 2626s return self._connection_for_bind( 2626s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 2626s return trans._connection_for_bind(engine, execution_options) 2626s :2: in _connection_for_bind 2626s ??? 2626s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 2626s ret_value = fn(self, *arg, **kw) 2626s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 2626s conn = bind.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________________ test_temporary_table[mysql_pymysql_conn] ___________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_temporary_table(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("test does not work with str connection") 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_temporary_table[postgresql_psycopg2_engine] _______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_temporary_table(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("test does not work with str connection") 2626s 2626s conn = request.getfixturevalue(conn) 2626s 2626s from sqlalchemy import ( 2626s Column, 2626s Integer, 2626s Unicode, 2626s select, 2626s ) 2626s from sqlalchemy.orm import ( 2626s Session, 2626s declarative_base, 2626s ) 2626s 2626s test_data = "Hello, World!" 2626s expected = DataFrame({"spam": [test_data]}) 2626s Base = declarative_base() 2626s 2626s class Temporary(Base): 2626s __tablename__ = "temp_test" 2626s __table_args__ = {"prefixes": ["TEMPORARY"]} 2626s id = Column(Integer, primary_key=True) 2626s spam = Column(Unicode(30), nullable=False) 2626s 2626s with Session(conn) as session: 2626s with session.begin(): 2626s > conn = session.connection() 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 2626s return self._connection_for_bind( 2626s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 2626s return trans._connection_for_bind(engine, execution_options) 2626s :2: in _connection_for_bind 2626s ??? 2626s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 2626s ret_value = fn(self, *arg, **kw) 2626s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 2626s conn = bind.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________________ test_temporary_table[postgresql_psycopg2_conn] ________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_temporary_table(conn, request): 2626s if conn == "sqlite_str": 2626s pytest.skip("test does not work with str connection") 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s __________________ test_invalid_engine[mysql_pymysql_engine] ___________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_invalid_engine(conn, request, test_frame1): 2626s if conn == "sqlite_buildin" or "adbc" in conn: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2626s ) 2626s ) 2626s 2626s conn = request.getfixturevalue(conn) 2626s msg = "engine must be one of 'auto', 'sqlalchemy'" 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________________ test_invalid_engine[mysql_pymysql_conn] ____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_invalid_engine(conn, request, test_frame1): 2626s if conn == "sqlite_buildin" or "adbc" in conn: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2626s ) 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_invalid_engine[postgresql_psycopg2_engine] ________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_invalid_engine(conn, request, test_frame1): 2626s if conn == "sqlite_buildin" or "adbc" in conn: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2626s ) 2626s ) 2626s 2626s conn = request.getfixturevalue(conn) 2626s msg = "engine must be one of 'auto', 'sqlalchemy'" 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________________ test_invalid_engine[postgresql_psycopg2_conn] _________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_invalid_engine(conn, request, test_frame1): 2626s if conn == "sqlite_buildin" or "adbc" in conn: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2626s ) 2626s ) 2626s 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_to_sql_with_sql_engine[mysql_pymysql_engine] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2626s """`to_sql` with the `engine` param""" 2626s # mostly copied from this class's `_to_sql()` method 2626s conn = request.getfixturevalue(conn) 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_to_sql_with_sql_engine[mysql_pymysql_conn] ________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2626s """`to_sql` with the `engine` param""" 2626s # mostly copied from this class's `_to_sql()` method 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_to_sql_with_sql_engine[postgresql_psycopg2_engine] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2626s """`to_sql` with the `engine` param""" 2626s # mostly copied from this class's `_to_sql()` method 2626s conn = request.getfixturevalue(conn) 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_to_sql_with_sql_engine[postgresql_psycopg2_conn] _____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2626s """`to_sql` with the `engine` param""" 2626s # mostly copied from this class's `_to_sql()` method 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ________________ test_options_sqlalchemy[mysql_pymysql_engine] _________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_options_sqlalchemy(conn, request, test_frame1): 2626s # use the set option 2626s conn = request.getfixturevalue(conn) 2626s with pd.option_context("io.sql.engine", "sqlalchemy"): 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _________________ test_options_sqlalchemy[mysql_pymysql_conn] __________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_options_sqlalchemy(conn, request, test_frame1): 2626s # use the set option 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _____________ test_options_sqlalchemy[postgresql_psycopg2_engine] ______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_options_sqlalchemy(conn, request, test_frame1): 2626s # use the set option 2626s conn = request.getfixturevalue(conn) 2626s with pd.option_context("io.sql.engine", "sqlalchemy"): 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_options_sqlalchemy[postgresql_psycopg2_conn] _______________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2626s def test_options_sqlalchemy(conn, request, test_frame1): 2626s # use the set option 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___________________ test_options_auto[mysql_pymysql_engine] ____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_options_auto(conn, request, test_frame1): 2626s # use the set option 2626s conn = request.getfixturevalue(conn) 2626s with pd.option_context("io.sql.engine", "auto"): 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____________________ test_options_auto[mysql_pymysql_conn] _____________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_options_auto(conn, request, test_frame1): 2626s # use the set option 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ________________ test_options_auto[postgresql_psycopg2_engine] _________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_options_auto(conn, request, test_frame1): 2626s # use the set option 2626s conn = request.getfixturevalue(conn) 2626s with pd.option_context("io.sql.engine", "auto"): 2626s > with pandasSQL_builder(conn) as pandasSQL: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________________ test_options_auto[postgresql_psycopg2_conn] __________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s test_frame1 = index A B C D 2626s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 2626s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_options_auto(conn, request, test_frame1): 2626s # use the set option 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d18360> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype_backend( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s # GH#50048 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d18360> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype_backend( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s # GH#50048 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d10360> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype_backend( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s # GH#50048 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d10360> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype_backend( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s # GH#50048 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s string_storage = 'python', func = 'read_sql_query' 2626s dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6cfc4a0> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype_backend( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s # GH#50048 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s string_storage = 'python', func = 'read_sql_query' 2626s dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6cfc4a0> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype_backend( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s # GH#50048 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s string_storage = 'python', func = 'read_sql_query' 2626s dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d04540> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype_backend( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s # GH#50048 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s string_storage = 'python', func = 'read_sql_query' 2626s dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d045e0> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype_backend( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s # GH#50048 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d04860> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2626s def test_read_sql_dtype_backend_table( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s if "sqlite" in conn and "adbc" not in conn: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason=( 2626s "SQLite actually returns proper boolean values via " 2626s "read_sql_table, but before pytest refactor was skipped" 2626s ) 2626s ) 2626s ) 2626s # GH#50048 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d04860> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2626s def test_read_sql_dtype_backend_table( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s if "sqlite" in conn and "adbc" not in conn: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason=( 2626s "SQLite actually returns proper boolean values via " 2626s "read_sql_table, but before pytest refactor was skipped" 2626s ) 2626s ) 2626s ) 2626s # GH#50048 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d04900> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2626s def test_read_sql_dtype_backend_table( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s if "sqlite" in conn and "adbc" not in conn: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason=( 2626s "SQLite actually returns proper boolean values via " 2626s "read_sql_table, but before pytest refactor was skipped" 2626s ) 2626s ) 2626s ) 2626s # GH#50048 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d049a0> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2626s def test_read_sql_dtype_backend_table( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s if "sqlite" in conn and "adbc" not in conn: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason=( 2626s "SQLite actually returns proper boolean values via " 2626s "read_sql_table, but before pytest refactor was skipped" 2626s ) 2626s ) 2626s ) 2626s # GH#50048 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s string_storage = 'python', func = 'read_sql_table' 2626s dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d04e00> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2626s def test_read_sql_dtype_backend_table( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s if "sqlite" in conn and "adbc" not in conn: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason=( 2626s "SQLite actually returns proper boolean values via " 2626s "read_sql_table, but before pytest refactor was skipped" 2626s ) 2626s ) 2626s ) 2626s # GH#50048 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s string_storage = 'python', func = 'read_sql_table' 2626s dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d04ea0> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2626s def test_read_sql_dtype_backend_table( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s if "sqlite" in conn and "adbc" not in conn: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason=( 2626s "SQLite actually returns proper boolean values via " 2626s "read_sql_table, but before pytest refactor was skipped" 2626s ) 2626s ) 2626s ) 2626s # GH#50048 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s string_storage = 'python', func = 'read_sql_table' 2626s dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d04f40> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2626s def test_read_sql_dtype_backend_table( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s if "sqlite" in conn and "adbc" not in conn: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason=( 2626s "SQLite actually returns proper boolean values via " 2626s "read_sql_table, but before pytest refactor was skipped" 2626s ) 2626s ) 2626s ) 2626s # GH#50048 2626s conn_name = conn 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s string_storage = 'python', func = 'read_sql_table' 2626s dtype_backend = 'numpy_nullable' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s dtype_backend_expected = .func at 0x703fe6d04fe0> 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2626s def test_read_sql_dtype_backend_table( 2626s conn, 2626s request, 2626s string_storage, 2626s func, 2626s dtype_backend, 2626s dtype_backend_data, 2626s dtype_backend_expected, 2626s ): 2626s if "sqlite" in conn and "adbc" not in conn: 2626s request.applymarker( 2626s pytest.mark.xfail( 2626s reason=( 2626s "SQLite actually returns proper boolean values via " 2626s "read_sql_table, but before pytest refactor was skipped" 2626s ) 2626s ) 2626s ) 2626s # GH#50048 2626s conn_name = conn 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] ___ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s func = 'read_sql' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2626s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] ____ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s func = 'read_sql' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2626s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s func = 'read_sql' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2626s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s func = 'read_sql' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2626s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s func = 'read_sql_table' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2626s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s func = 'read_sql_table' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2626s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s func = 'read_sql_table' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2626s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s func = 'read_sql_table' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2626s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s func = 'read_sql_query' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2626s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s func = 'read_sql_query' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2626s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s func = 'read_sql_query' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2626s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = dtype_backend_data 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s func = 'read_sql_query' 2626s dtype_backend_data = a b c d e f g h 2626s 0 1 1 1.5 1.5 True True a a 2626s 1 2 2.0 False False b b 2626s 2 3 3 2.5 2.5 None True c None 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2626s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______________ test_chunksize_empty_dtypes[mysql_pymysql_engine] _______________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_chunksize_empty_dtypes(conn, request): 2626s # GH#50245 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s dtypes = {"a": "int64", "b": "object"} 2626s df = DataFrame(columns=["a", "b"]).astype(dtypes) 2626s expected = df.copy() 2626s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______________ test_chunksize_empty_dtypes[mysql_pymysql_conn] ________________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_chunksize_empty_dtypes(conn, request): 2626s # GH#50245 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___________ test_chunksize_empty_dtypes[postgresql_psycopg2_engine] ____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_chunksize_empty_dtypes(conn, request): 2626s # GH#50245 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2626s ) 2626s conn = request.getfixturevalue(conn) 2626s dtypes = {"a": "int64", "b": "object"} 2626s df = DataFrame(columns=["a", "b"]).astype(dtypes) 2626s expected = df.copy() 2626s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____________ test_chunksize_empty_dtypes[postgresql_psycopg2_conn] _____________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s def test_chunksize_empty_dtypes(conn, request): 2626s # GH#50245 2626s if "adbc" in conn: 2626s request.node.add_marker( 2626s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2626s ) 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] ___ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s func = 'read_sql', dtype_backend = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] ____ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s func = 'read_sql', dtype_backend = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s func = 'read_sql', dtype_backend = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s func = 'read_sql', dtype_backend = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _______ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s func = 'read_sql', dtype_backend = 'numpy_nullable' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] ________ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s func = 'read_sql', dtype_backend = 'numpy_nullable' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ___ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] ____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s func = 'read_sql', dtype_backend = 'numpy_nullable' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ____ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _____ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s func = 'read_sql', dtype_backend = 'numpy_nullable' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s func = 'read_sql_query', dtype_backend = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s func = 'read_sql_query', dtype_backend = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s func = 'read_sql_query', dtype_backend = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s func = 'read_sql_query', dtype_backend = 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s ___ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] ____ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2626s request = > 2626s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s ____ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _____ 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s > sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3.13/socket.py:864: in create_connection 2626s raise exceptions[0] 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s address = ('localhost', 3306), timeout = 10, source_address = None 2626s 2626s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2626s source_address=None, *, all_errors=False): 2626s """Connect to *address* and return the socket object. 2626s 2626s Convenience function. Connect to *address* (a 2-tuple ``(host, 2626s port)``) and return the socket object. Passing the optional 2626s *timeout* parameter will set the timeout on the socket instance 2626s before attempting to connect. If no *timeout* is supplied, the 2626s global default timeout setting returned by :func:`getdefaulttimeout` 2626s is used. If *source_address* is set it must be a tuple of (host, port) 2626s for the socket to bind as a source address before making the connection. 2626s A host of '' or port 0 tells the OS to use the default. When a connection 2626s cannot be created, raises the last error if *all_errors* is False, 2626s and an ExceptionGroup of all errors if *all_errors* is True. 2626s """ 2626s 2626s host, port = address 2626s exceptions = [] 2626s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2626s af, socktype, proto, canonname, sa = res 2626s sock = None 2626s try: 2626s sock = socket(af, socktype, proto) 2626s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2626s sock.settimeout(timeout) 2626s if source_address: 2626s sock.bind(source_address) 2626s > sock.connect(sa) 2626s E ConnectionRefusedError: [Errno 111] Connection refused 2626s 2626s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2626s 2626s During handling of the above exception, another exception occurred: 2626s 2626s self = 2626s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2626s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'mysql_pymysql_conn' 2626s request = > 2626s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2626s with mysql_pymysql_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2626s self.connect() 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s self = , sock = None 2626s 2626s def connect(self, sock=None): 2626s self._closed = False 2626s try: 2626s if sock is None: 2626s if self.unix_socket: 2626s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2626s sock.settimeout(self.connect_timeout) 2626s sock.connect(self.unix_socket) 2626s self.host_info = "Localhost via UNIX socket" 2626s self._secure = True 2626s if DEBUG: 2626s print("connected using unix_socket") 2626s else: 2626s kwargs = {} 2626s if self.bind_address is not None: 2626s kwargs["source_address"] = (self.bind_address, 0) 2626s while True: 2626s try: 2626s sock = socket.create_connection( 2626s (self.host, self.port), self.connect_timeout, **kwargs 2626s ) 2626s break 2626s except OSError as e: 2626s if e.errno == errno.EINTR: 2626s continue 2626s raise 2626s self.host_info = "socket %s:%d" % (self.host, self.port) 2626s if DEBUG: 2626s print("connected using socket") 2626s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2626s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2626s sock.settimeout(None) 2626s 2626s self._sock = sock 2626s self._rfile = sock.makefile("rb") 2626s self._next_seq_id = 0 2626s 2626s self._get_server_information() 2626s self._request_authentication() 2626s 2626s # Send "SET NAMES" query on init for: 2626s # - Ensure charaset (and collation) is set to the server. 2626s # - collation_id in handshake packet may be ignored. 2626s # - If collation is not specified, we don't know what is server's 2626s # default collation for the charset. For example, default collation 2626s # of utf8mb4 is: 2626s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2626s # - MySQL 8.0: utf8mb4_0900_ai_ci 2626s # 2626s # Reference: 2626s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2626s # - https://github.com/wagtail/wagtail/issues/9477 2626s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2626s self.set_character_set(self.charset, self.collation) 2626s 2626s if self.sql_mode is not None: 2626s c = self.cursor() 2626s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2626s c.close() 2626s 2626s if self.init_command is not None: 2626s c = self.cursor() 2626s c.execute(self.init_command) 2626s c.close() 2626s 2626s if self.autocommit_mode is not None: 2626s self.autocommit(self.autocommit_mode) 2626s except BaseException as e: 2626s self._rfile = None 2626s if sock is not None: 2626s try: 2626s sock.close() 2626s except: # noqa 2626s pass 2626s 2626s if isinstance(e, (OSError, IOError)): 2626s exc = err.OperationalError( 2626s CR.CR_CONN_HOST_ERROR, 2626s f"Can't connect to MySQL server on {self.host!r} ({e})", 2626s ) 2626s # Keep original exception and traceback to investigate error. 2626s exc.original_exception = e 2626s exc.traceback = traceback.format_exc() 2626s if DEBUG: 2626s print(exc.traceback) 2626s > raise exc 2626s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2626s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s request = > 2626s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s conn = request.getfixturevalue(conn) 2626s table = "test" 2626s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2626s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2626s return func(*args, **kwargs) 2626s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2626s return sql.to_sql( 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2626s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2626s return SQLDatabase(con, schema, need_transaction) 2626s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2626s con = self.exit_stack.enter_context(con.connect()) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] __ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s conn = 'postgresql_psycopg2_conn' 2626s request = > 2626s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2626s 2626s @pytest.mark.parametrize("conn", all_connectable) 2626s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2626s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2626s def test_read_sql_dtype(conn, request, func, dtype_backend): 2626s # GH#50797 2626s > conn = request.getfixturevalue(conn) 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2626s fixturedef = self._get_active_fixturedef(argname) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2626s fixturedef.execute(request=subrequest) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2626s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2626s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2626s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2626s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2626s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2626s return (yield) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2626s result = call_fixture_func(fixturefunc, request, kwargs) 2626s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2626s fixture_result = next(generator) 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2626s with postgresql_psycopg2_engine.connect() as conn: 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________________________ test_psycopg2_schema_support _________________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s 2626s @pytest.mark.db 2626s def test_psycopg2_schema_support(postgresql_psycopg2_engine): 2626s conn = postgresql_psycopg2_engine 2626s 2626s # only test this for postgresql (schema's not supported in 2626s # mysql/sqlite) 2626s df = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 2626s 2626s # create a schema 2626s > with conn.connect() as con: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3905: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s _________________________ test_self_join_date_columns __________________________ 2626s self = 2626s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s connection = None, _has_events = None, _allow_revalidate = True 2626s _allow_autobegin = True 2626s 2626s def __init__( 2626s self, 2626s engine: Engine, 2626s connection: Optional[PoolProxiedConnection] = None, 2626s _has_events: Optional[bool] = None, 2626s _allow_revalidate: bool = True, 2626s _allow_autobegin: bool = True, 2626s ): 2626s """Construct a new Connection.""" 2626s self.engine = engine 2626s self.dialect = dialect = engine.dialect 2626s 2626s if connection is None: 2626s try: 2626s > self._dbapi_connection = engine.raw_connection() 2626s 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s 2626s The above exception was the direct cause of the following exception: 2626s 2626s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2626s 2626s @pytest.mark.db 2626s def test_self_join_date_columns(postgresql_psycopg2_engine): 2626s # GH 44421 2626s conn = postgresql_psycopg2_engine 2626s from sqlalchemy.sql import text 2626s 2626s create_table = text( 2626s """ 2626s CREATE TABLE person 2626s ( 2626s id serial constraint person_pkey primary key, 2626s created_dt timestamp with time zone 2626s ); 2626s 2626s INSERT INTO person 2626s VALUES (1, '2021-01-01T00:00:00Z'); 2626s """ 2626s ) 2626s > with conn.connect() as con: 2626s 2626s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3989: 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2626s return self._connection_cls(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2626s Connection._handle_dbapi_exception_noconnection( 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2626s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2626s self._dbapi_connection = engine.raw_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2626s return self.pool.connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2626s return _ConnectionFairy._checkout(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2626s fairy = _ConnectionRecord.checkout(pool) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2626s rec = pool._do_get() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2626s return self._create_connection() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2626s return _ConnectionRecord(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2626s self.__connect() 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2626s with util.safe_reraise(): 2626s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2626s raise exc_value.with_traceback(exc_tb) 2626s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2626s self.dbapi_connection = connection = pool._invoke_creator(self) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2626s return dialect.connect(*cargs, **cparams) 2626s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2626s return self.loaded_dbapi.connect(*cargs, **cparams) 2626s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2626s 2626s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2626s connection_factory = None, cursor_factory = None 2626s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2626s kwasync = {} 2626s 2626s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2626s """ 2626s Create a new database connection. 2626s 2626s The connection parameters can be specified as a string: 2626s 2626s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2626s 2626s or using a set of keyword arguments: 2626s 2626s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2626s 2626s Or as a mix of both. The basic connection parameters are: 2626s 2626s - *dbname*: the database name 2626s - *database*: the database name (only as keyword argument) 2626s - *user*: user name used to authenticate 2626s - *password*: password used to authenticate 2626s - *host*: database host address (defaults to UNIX socket if not provided) 2626s - *port*: connection port number (defaults to 5432 if not provided) 2626s 2626s Using the *connection_factory* parameter a different class or connections 2626s factory can be specified. It should be a callable object taking a dsn 2626s argument. 2626s 2626s Using the *cursor_factory* parameter, a new default cursor factory will be 2626s used by cursor(). 2626s 2626s Using *async*=True an asynchronous connection will be created. *async_* is 2626s a valid alias (for Python versions where ``async`` is a keyword). 2626s 2626s Any other keyword parameter will be passed to the underlying client 2626s library: the list of supported parameters depends on the library version. 2626s 2626s """ 2626s kwasync = {} 2626s if 'async' in kwargs: 2626s kwasync['async'] = kwargs.pop('async') 2626s if 'async_' in kwargs: 2626s kwasync['async_'] = kwargs.pop('async_') 2626s 2626s dsn = _ext.make_dsn(dsn, **kwargs) 2626s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2626s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2626s E Is the server running on that host and accepting TCP/IP connections? 2626s E 2626s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2626s 2626s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2626s =============================== warnings summary =============================== 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:895 2626s /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 2626s pytest.param("mysql_pymysql_engine", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:896 2626s /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 2626s pytest.param("mysql_pymysql_conn", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:900 2626s /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 2626s pytest.param("mysql_pymysql_engine_iris", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:901 2626s /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 2626s pytest.param("mysql_pymysql_conn_iris", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:905 2626s /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 2626s pytest.param("mysql_pymysql_engine_types", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:906 2626s /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 2626s pytest.param("mysql_pymysql_conn_types", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:910 2626s /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 2626s pytest.param("postgresql_psycopg2_engine", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:911 2626s /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 2626s pytest.param("postgresql_psycopg2_conn", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:915 2626s /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 2626s pytest.param("postgresql_psycopg2_engine_iris", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:916 2626s /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 2626s pytest.param("postgresql_psycopg2_conn_iris", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:920 2626s /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 2626s pytest.param("postgresql_psycopg2_engine_types", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:921 2626s /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 2626s pytest.param("postgresql_psycopg2_conn_types", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:954 2626s /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 2626s pytest.param("postgresql_adbc_conn", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:958 2626s /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 2626s pytest.param("postgresql_adbc_iris", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:959 2626s /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 2626s pytest.param("sqlite_adbc_iris", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:963 2626s /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 2626s pytest.param("postgresql_adbc_types", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:964 2626s /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 2626s pytest.param("sqlite_adbc_types", marks=pytest.mark.db), 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3896 2626s /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 2626s @pytest.mark.db 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3971 2626s /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 2626s @pytest.mark.db 2626s 2626s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py:1143 2626s /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 2626s @pytest.mark.skip_ubsan 2626s 2626s io/test_sql.py: 1535 warnings 2626s tools/test_to_datetime.py: 978 warnings 2626s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=18322) is multi-threaded, use of fork() may lead to deadlocks in the child. 2626s pid = os.fork() 2626s 2626s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 2626s /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-bxyzazao' 2626s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 2626s 2626s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 2626s /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-z0pp1h84' 2626s config.cache.set("cache/lastfailed", self.lastfailed) 2626s 2626s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 2626s /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-n2nww0vf' 2626s session.config.cache.set(STEPWISE_CACHE_DIR, []) 2626s 2626s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 2626s =========================== short test summary info ============================ 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 2626s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 2626s 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] 2626s 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] 2626s 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] 2626s 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] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 2626s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 2626s = 588 failed, 1481 passed, 400 skipped, 54 xfailed, 2536 warnings, 592 errors in 829.93s (0:13:49) = 2627s autopkgtest [20:44:19]: test ignoredtests: -----------------------] 2629s ignoredtests PASS 2629s autopkgtest [20:44:21]: test ignoredtests: - - - - - - - - - - results - - - - - - - - - - 2629s autopkgtest [20:44:21]: @@@@@@@@@@@@@@@@@@@@ summary 2629s command1 PASS 2629s unittests3 PASS 2629s ignoredtests PASS 2646s nova [W] Skipping flock for amd64 2646s Creating nova instance adt-questing-i386-pandas-20250503-200032-juju-7f2275-prod-proposed-migration-environment-15-826e4b4f-5ebf-4e69-9ba1-3b87528980b6 from image adt/ubuntu-questing-amd64-server-20250503.img (UUID 57b7c1b6-ad80-4bdb-b031-36f045f7f3b3)... 2646s nova [W] Timed out waiting for 2708b87a-430e-4356-96d0-a7d84a325b52 to get deleted.